?
Solved

Procmail forwarding , but not if bounced!

Posted on 2009-04-06
6
Medium Priority
?
574 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 81

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 81

Accepted Solution

by:
arnold earned 1000 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 81

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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.:
Suggested Courses
Course of the Month14 days, 12 hours left to enroll

840 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