ProcMail Installation and Configuration Guide
ProcMail stands for Mail Processing, it allows you to process your incoming mail and then sort it into separate folders/file. ProcMail can be used to setup a vacation message or to forward your mail to another email address. All in all, it can be used for many things and I don't even know them all :) I will break this guide into two parts: install and setup.
1) Install ProcMail
Download the source from the following URL: http://www.procmail.org. You should get a file that looks similar to this procmail-3.22.tar.gz. Now let's begin installing :)
mv procmail-3.22.tar.gz /tmp; cd /tmp tar xzf procmail-3.22.tar.gz; cd procmail-3.22 make make BASENAME=/usr/local/procmail install
2) After Install Instructions
sudo chown 0:0 -R /usr/local/procmail sudo chmod 6755 /usr/local/procmail/bin/procmail sudo chmod 2755 /usr/local/procmail/bin/lockfile
3) Setup Instructions
Any time mail comes to the server, whether the mail server is running sendmail or exim or any other mail server application, by default most of the mail services look to "~/.forward" file. If the file exists then mail is either forwarded to the email address that is in the .forward file, or the mail server executes whatever is in that file. To use procmail we need to add an entry in .forward so it is executed whenever an email comes in. So if we place the following into our "~/.forward" file we should be all set.
|IFS=' '&&exec /usr/local/procmail/bin/procmail -f-||exit 75 #username
*note replace username with your username :)
4) Example to use spamassassin with procmail
Spamassassin is a linux utility which finds spam in mail and adds a header to the email message to mark as spam. Spamassassin is a perl-based application. Using your favorite text editor put the following into your "~/.procmailrc"
# # .procmailrc # DEFAULT=/var/mail/$LOGNAME UMASK=007 # Look for spam :0fw |/usr/local/perl/bin/spamassassin :0 *^X-Spam-Flag:Yes *^Subject: POTENTIAL SPAM: $HOME/mail/spam :0: $DEFAULT
Here is what happens, each message is run through the spamassassin utility which if it is spam, will mark it so, it will do it by adding the "X-Spam-Flag:Yes" header field and prepend "POTENTIAL SPAM:" to the subject line. So after we run the message through spamassassin when then check if the above has been set and if so we move the message to the spam folder, see what was simple, wasn't it ? :)
5) Example to forward messages to your gmail account
Place the following into your "~/.procmailrc"
# # .procmailrc # DEFAULT=/var/mail/$LOGNAME UMASK=007 # Forward all mail to gmail :0c ! your_gmail_address@gmail.com :0: $DEFAULT
Related posts: