From: mogujw on
I tried posting this question on linuxforums.org but havn't had a
reply in two days. Hopefully someone here can help with this.

I'm trying to set up a filter on our server to check the headers of
incoming email to see if it is being forwarded from gmail, and if not,
forwarding the message to gmail where gmail can act as a spam filter
and forward the mail back. This method is talked about at a few sites
that I've listed at the end of this message. It seems like the best
option because it doesn't require too many changes to existing mail
retrieval, and should be a simple setup and removal if necessary.

I'm a little new to using linux command shell and am having some
trouble getting the configurations right to get this to work (server
is running Redhat Enterprise Linux 4ES, I'm using the web-based shell
through Webmin). We are using postfix, and appear to have procmail
installed, but it isn't being used. Those tutorials mention using
procmailrc to set up the filter, but if there is another option let me
know!


Replacing MYUSERNAME and USER with their respective values:

.procmailrc file put into root/home/MYUSERNAME/

Code:
------------------------------------------------------------
DEFAULT=/var/spool/mail/MYUSERNAME
MAILDIR=$HOME/mail
PMDIR=$HOME/.procmail
LOGFILE=$PMDIR/log
SHELL=/bin/sh

# forward to gmail account for spam filtering
:0
* !X-Forwarded-For: USER(a)gmail.com
{
:0fw
| formail -IDelivered-To

:0
! USER(a)gmail.com
}
------------------------------------------

This is supposed to enable procmail?
.forward file put into root/home/, I tried renaming as .forward
and .forward.postfix
Code:
-----------------
"|/usr/bin/procmail -t"
---------------

Nothing at all seemed to change when I tried this. Incoming emails
continued to be sent as normal and I don't know how to check if it was
even being forwarded through procmail and if there was a problem with
the .procmailrc. Can anyone help?

From the mail server configs, our mail storage type is 'mbox', mail
file directory style is 'mail/username', mail file in home directory
is 'mbox', user mail file location is '/var/spool/mail', and user
forward files set to '$z/.forward.$w:$z/.forward' if that's relevant.


Links relating to this:
Using Gmail as a Spam Filter
http://mboffin.com/post.aspx?id=1636

Double-Pass Spam Filtering with Gmail -
http://wiki.dreamhost.com/index.php/Double-Pass_Spam_Filtering_with_Gmail

Make GMailÂ’s Spam Filter Work For You
http://blog.rafferty.org/2008/01/02/make-gmails-spam-filter-work-for-you/

Spam Filtering using Google's GMAIL
http://galileo.phys.virginia.edu/research/groups/hep/aag/norman/email-filtering.html