[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Procmail forwarding , but not if bounced!

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

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 80

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
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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 80

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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

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.…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
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.:
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

656 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