Solved

Procmail forwarding , but not if bounced!

Posted on 2009-04-06
6
549 Views
Last Modified: 2012-05-06

I have a server with procmail. My users can set up a forwarding to external addresses if they want to in the .procmailrc file (I have written a front end to this) so the format of the configuration file is maintained.

The problem is that if the external email address is un-deliverable the bounce then gets forwarded and then it loops forever.

I have the code below which adds a header "X-glimwormForwarded: yes" and then checks for this before forwarding the next time.  The problem is that this condition is never matched so it just keeps on in its loop and I can't work out why.

I checked and the bounced message does have the additional field in its header when it is returned.

Anybody got a clue?

:0

* ^X-glimwormForwarded: yes

${MAILDIR}/
 
 

:0

{

        :0 fw

        | ${FORMAIL} -A"X-glimwormForwarded: yes"
 

        :0

        !non-working-address@hotmail.com

}

Open in new window

0
Comment
Question by:jonathanrcarter
  • 3
  • 2
6 Comments
 
LVL 76

Expert Comment

by:arnold
ID: 24077931
Add a Check for MAILERDAEMON: http://nlsn.free.fr/lin-docs/procmail/man/procmailrc.html
FROM_MAILER, FROM_DAEMON
These should eliminate notices to bounces, as well as to list-servers.
0
 

Author Comment

by:jonathanrcarter
ID: 24078428
I thought of this originally but if the user sends a mail to an un-related address and receives a bounce would't a rule like this also block this bounce, which should be passed through.

The reason I added the header was to differentiate those which I have forwarded and that have bounced from those which have bounced "legitimately".

Or am I thinking too deep? (you can tell me)

0
 
LVL 76

Accepted Solution

by:
arnold earned 250 total points
ID: 24078572
You should add the rule
! ^(From_Mailer|From_DAEMON)

You could add a check for the body of the message to make sure

:B
! ^X-glimwormForwarded: yes
{
enclose your stuff.

}

The problem is not all NDR (bounce messages include the complete original header).

Depending on your mail server, you could add a SENDER, i.e. username-forward.
This way a bounce from the forwarded message will be sent to username-forward@yourdomain which you then can handle differently from a bounce that is sent to user@domain.

0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 23

Expert Comment

by:Maciej S
ID: 24091762
There is an example in manual :)
You need to make it one rule, not two separate ones.

If you don't want to use X-Loop header, just change it to whatever you want (X-glimwormForwarded for example).
:0 c

* !^X-Loop: yourname@your.main.mail.address

| formail -A "X-Loop: yourname@your.main.mail.address" | \

   $SENDMAIL -oi yourname@the.other.account

Open in new window

0
 
LVL 76

Expert Comment

by:arnold
ID: 24092248
The problem the individual is trying to address is in the event the yourname@the.other.account is no longer valid and the message bounces.  The X-Loop will not exist in the header of the bounce message, but will exist in the body of the bounce message.

The use of the -fyouremail-bounvce@yourdomain to specify an alternate email address to which bounces should be sent.
Adding reply-to or similar on error reply address, will not work either because the bounce mechanism uses the email address provided during the initial SMTP session where the sender and the recipient email addresses are provided.
0
 

Author Closing Comment

by:jonathanrcarter
ID: 31567010
This solved the problem exactly as I wanted it solved.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Join & Write a Comment

Daily system administration tasks often require administrators to connect remote systems. But allowing these remote systems to accept passwords makes these systems vulnerable to the risk of brute-force password guessing attacks. Furthermore there ar…
How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now