[ DirectAdmin. ]
To use the
procmail program to filter incoming mail, please follow these two steps
First, create a file called
.procmailrc within your home directory. Into that insert
ORGMAIL=Maildir/ DEFAULT=Maildir/ :0 $ORGMAIL
Second, create a file called
.forward in your home directory,
and insert into that exactly this line, containing no blanks:
Following the steps above in the order given will ensure no loss of mail while files are being edited.
Now procmail filtering should be active, and procmail will run whenever mail arrives, and will simply deliver it into your mailbox, which is a directory Maildir that holds mail in maildir format.
Verify that incoming mail is being correctly received and delivered. Check mail using any of methods described in our DirectAdmin pages.
One you are sure that your mail is not being lost, you can further edit your
.procmailrc file and add rules for mail filtering and mail delivery.
Avoid bouncing mail. Older procmail recipes on the Internet sometimes make procmail exit with a 67 exit code, which is supposed to bounce mail back to the sender. This is a bad idea, because it creates backscatter. Instead of bouncing unwanted mail, just discard it by writing it to /dev/null.
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.
An longer and more generic
.procmailrc file can be found on this page: Example generic .procmailrc file.
In normal use, most people will enable logging to a log file. The log file will grow endlessly unless you take steps to prune it. This can be easily done automatically using the logrotate program, which can be run once a day from a cron job. Details are described on this page: Logrotate for pruning log files.