My server hosts several email addresses, for both individuals and lists. I do not provide SMTP or POP for these users... I simply forward each user's email to their "real" email address (or to a list of addresses) using the mail server's "aliases" file.
I am currently using Gmail as a spam filter in the following cumbersome way: All users' mail is initially forwarded to a single Gmail account. Using the Filter feature of Gmail, I forward it back to my server, but to a modified email address. Finally I forward it to the real address. It works because Gmail applies the spam filter before it applies the Filter feature.
So for users "joe" and "bob" my aliases file (on mysite.com) would have:
joe: [email protected]
joe-nospam: [email protected]
bob: [email protected]
bob-nospam: [email protected]
In [email protected], I set up the filters:
[email protected] forwards to [email protected]
[email protected] forwards to [email protected]
This is basically working, except it's a pain to set up new users. Also, I'm wondering if I could get better quality spam filtering by using the officially sanctioned method of pointing the MX record of mysite.com to gmail.com. How could I duplicate my functionality by using the MX record in that way? Any other ideas?
I'd prefer to not install an anti-spam solution on my own server, because in my experience, none are as good as gmail.
EDIT:
One complication with the MX / Google Apps solution is that for some email addresses I use the "pipe" feature of the aliases file to pipe the message through my own script. So I would want a way to forward some of the messages back to my server anyway. And once I have pointed the MX record for myserver.com to Google, how can any messages be sent back to my server?
No offense, but that's pretty messed up.
Just cut out all of the complications and move your domain(s) over to Google Apps. It's free (for up to 50 users/domain). You'll get sane management tools, great web interface, POP3/IMAP if your users want it, mobile push notification, etc.
Regarding your edit: I do this frequently, using
fetchmail
(run via cron) to retrieve messages via IMAP and then pipe them through a custom parser.A gmail/gapps account can forward all email delivered to it (after spam filtering) to another address (preferably forward and delete if you don't intend to check it). The account can also have at least a fair number of aliases on it. When a message is sent to an alias, gmail tags a "X-Remote-Delivered-To:" header containing that alias before delivering it to the account(s). With that combination, you should be able to have your server under a sub/different domain, use only one of the 50 accounts with many aliases pointing to it, and use procmail to deliver/pipe to a script as needed. In addition it'd all be push, with no polling of any gmail account needed.
I would use the Google Apps solution as mentioned above, but instead of
fetchmail
I would recommend taking a look atofflineimap
. It has some advanced capabilities like syncing directly between two IMAP servers, running pre and post hooks, etc. You might find this useful when migrating old email, as well.