Solved

Procmail forwarding , but not if bounced!

Posted on 2009-04-06
6
564 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
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 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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
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…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
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.

690 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