User Tools

Site Tools


Example .procmailrc file for mail forwarding

[ Classic Linux and DirectAdmin. ]

Normal mail forwarding via a  .forward  file will also forward some spam, which may be rejected by the destination site, and will bounce back to the original possibly-forged sender, causing backscatter.

This example  .procmailrc  file can be used to forward mail with procmail to an off-site email address. It will try to not forward any spam.

For best results, use this in combination with ability of mail services such as Gmail and Yahoo to access your mailbox via POP.

Non-spam mail will be forwarded immediately. Some messages will not get forwarded if they appear to be spam. Any that are not forwarded will then be retrieved by the other site via POP.

Having a site retrieve your mail via POP usually causes a delay, as the polling via POP occurs every few minutes. Using procmail for forwarding eliminates this delay for almost all messages. The few messages that proccmail skips will then be pulled via POP.

# $Id: procmailrc.std.forward 13498 2021-03-01 16:41:36Z svn $
# $URL: svn+ssh:// $

# Minimal .procmailrc for forwarding to a different mail service, e.g., Gmail, Yahoo, etc.
# Objective: Don't forward spam, preserve original envelope sender.

# Note: this log file will grow endlessly. Once forwarding is working, you should
# comment out the LOGFILE line.  Or you can keep logging enabled and set up
# log file rollover as described on this page:

# verbose log, yes or no

# only a precaution

# Required in DirectAdmin, optional in Classic Linux.

# Preserve original envelope sender, as recommended by Google.
SENDER=`formail -c -x Return-Path`

# Forward not-spam to my off-site address, e.g., at Gmail, Yahoo, etc.
* !^X-Spam-Level: \*\*\*\*
* !^X-Spam: Yes

# End of minimal .procmailrc for forwarding to a different mail service, e.g., Gmail, Yahoo, etc.
hints/example_procmailrc_file_forwarding.txt · Last modified: 2021/03/01 08:42 by admin