Solved

Procmail forwarding , but not if bounced!

Posted on 2009-04-06
6
561 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 78

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 78

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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
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 78

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

Industry Leaders: 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

Suggested Solutions

Title # Comments Views Activity
Zimbra on Amazon Linux help 7 152
Unbreakable Oracle Linux 6.8 installation problem 9 61
Logrotate Every Saturday 5 40
bash: ./Facebooker.pl :Permission Denied 9 50
I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
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…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

739 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