Hints
* Top
* Top
[ Classic Linux and DirectAdmin. ]
Note. This is under development and will be revised. You can find a minimal simplified .procmailrc
file for forwarding mail to an off-site address on this page: Example .procmailrc file for mail forwarding.
# $Id: procmailrc.form 13440 2021-02-02 17:20:59Z svn $ # $URL: svn+ssh://svn@svn.rahul.net/home/svn/main/trunk/stdpgm/procmailrc.form $ # This example .procmailrc file should be valid in both the Classic Linux # and the DirectAdmin environments. # Examples in this file have been only briefly tested. Editing changes # might have introduced minor errors. Before deploying for production use, # please test carefully so you don't lose mail. # In this file, a single '#' begins a normal comment. # A double '##' is used to comment out either a line of code # or entire blocks of lines. # Blocks of lines that belong together are enclosed within {{{ ... }}} comments. # procmail log is saved in a subdirectory called “logs”. # Make the subdirectory with the command “mkdir ~/logs”. # To rotate procmail logs, so they don't fill up storage, the logrotate # command can be used from a cron job, as described elsewhere. LOGFILE=$HOME/logs/procmail.log # verbose log, yes or no ##VERBOSE=no VERBOSE=yes # show successful delivery for all recipes, not just the final one LOGABSTRACT=all # only a precaution SHELL=/bin/sh ## # Convenience symbols for pattern matching in shell commands. ## # Note: Definition of TAB should be a literal tab character. ## TAB = " " ## SPACE = " " ## WS = "$TAB$SPACE" # Force default mailbox to be our Maildir mailbox. # Required in DirectAdmin, optional in Classic Linux. ORGMAIL=Maildir/ DEFAULT=Maildir/ # 1^0 causes multiple conditions to be ORd. ## # Change empty subject to '(none)' {{{ ## ## :0fhw ## * 1^0 !^Subject:$ ## * 1^0 ^Subject:[$WS]*$ ## | formail -i 'Subject: (none)' ## ## # }}} ## # {{{ ## ## # Into a maildir format folder called “orexample” file messages that ## # satisfy one or more of the listed conditions. ## ## :0 ## * 1^0 ^From a@example\.com ## * 1^0 ^From b@example\.com ## * 1^0 ^TOc@example\.com ## * 1^0 ^Subject: some subject ## Maildir/.orexample/ ## ## # }}} # Without 1^0, multiple conditions are ANDed. ## # {{{ ## ## # Into a maildir format folder called “andexample” file messages that ## # satisfy all of the listed conditions. ## ## :0 ## * ^From c@example\.com ## * ^TOd@example\.com ## * ^Subject: another subject ## Maildir/.andexample/ ## ## # }}} ## # {{{ ## ## # Into an mbox format folder called “legacyandexample” file messages ## # that satisfy all of the listed conditions. Note: mbox format is a ## # legacy format that is not recommended for normal use. ## ## :0 ## * ^From c@example\.com ## * ^TOd@example\.com ## * ^Subject: another subject ## Mail/legacyandexample ## ## # }}} ## # {{{ ## ## # Mail forwarding without changing envelope sender. This is the ## # usual method of mail forwarding. ## ## # Note: Antispam techniques SPF, DKIM, and DMARC are in common use by ## # many sending domains, and may cause forwarded mail to be bounced, ## # lost, or filed into a spam folder. Generally, mail forwarding is a ## # bad idea and not recommended. If you must do mail forwarding, don't ## # forward spam. Service providers that receive much spam from us (even ## # if forwarded to yourself) may treat us as a spam site and begin ## # rejecting all mail from you, or all mail from our servers. ## ## # Forward selected mail to you@example.com, preserving the original ## # envelope sender. This is how you forward to any of the big free email ## # providers like Gmail, Hotmail, Yahoo. ## ## # Don't forward spam. Check for a SpamAssassin header X-Spam-Level ## # (don't forward if 5 or more stars) and an rspamd header X-Spam (if ## # Yes, typically spam level 6 or more). ## ## # ## # :0 used below means forward and don't retain original. ## # :0c would mean forward a copy and retain original. ## ## :0c ## * ^From:.*someuser@example\.com ## * !^X-Spam-Level: \*\*\*\*\* ## * !^X-Spam: Yes ## ! you@example.com ## ## # }}} ## # {{{ ## ## # Mail forwarding with modified envelope sender. ## ## # Forward selected mail to you@example.com, explicitly setting the ## # envelope sender to me@example.com. ## ## # Only if you really need this. ## ## # Don't forward spam. Check for a SpamAssassin header X-Spam-Level ## # (don't forward if 5 or more stars) and an rspamd header X-Spam (if ## # Yes, typically spam level 6 or more). ## ## # :0 used below means forward and don't retain original. ## # :0c would mean forward a copy and retain original. ## ## :0c ## * ^From:.*someuser@example\.com ## * !^X-Spam-Level: \*\*\*\*\* ## * !^X-Spam: Yes ## |/usr/sbin/sendmail -oi -fme@example.com you@example.com ## ## # }}} # Anything that has not matched so far goes into our default Maildir. # # Incorrect: Maildir # Incorrect: Maildir/. # Correct: Maildir/ :0 Maildir/