Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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: myDummyEmail@gmail.com
joe-nospam: real.joe@aol.com
bob: myDummyEmail@gmail.com
bob-nospam: real.bob@yahoo.com

In myDummyEmail@gmail.com, I set up the filters:

To=joe@mysite.com forwards to joe-nospam@mysite.com
To=bob@mysite.com forwards to bob-nospam@mysite.com

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?

share|improve this question
1  
I don't even want to know what the SMTP headers look like on these messages. –  EEAA Dec 15 '10 at 3:24
2  
You win my vote for "The Most Elaborate Workaround for Not Wanting to Set Up a SPAM Filtering System" award. –  John Gardeniers Dec 15 '10 at 3:53

3 Answers 3

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.

share|improve this answer
    
What if I want more than 50 and don't want to pay? –  JoelFan Dec 15 '10 at 3:31
    
Plus, see my edit for an additional complication. –  JoelFan Dec 15 '10 at 3:36
1  
Well then pay up. Honestly, you get what you pay for. What happens when/if Gmail shuts down the account you're currently using. This does happen, especially if they catch wind of what is really an abuse of their system. You admitted that your current system is cumbersome and sub-optimal. If you need more than 50 accounts, you'll need to pay up. Even the paid version of GApps is a steal for the price. –  EEAA Dec 15 '10 at 3:37
    
Are you sure my current system is abuse? –  JoelFan Dec 15 '10 at 3:38
1  
From Google's TOS: "You specifically agree not to access (or attempt to access) any of the Services through any automated means". Sounds like abuse to me. –  EEAA Dec 15 '10 at 3:42

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.

share|improve this answer
    
I like that because it involves the least change to my current "system"! Questions: (1) Are you sure the subdomain would work (e.g. myserver.com MX points to gmail.com, and nospam.myserver.com MXpoints to myserver.com)? I am using GoDaddy for DNS (not hosting). (2) How do I get postfix to use the "X-Remove-Delivered-To" header instead of "To" for processing my own aliases file? –  JoelFan Dec 15 '10 at 14:11
    
I'm not familiar with GoDaddy's DNS config tool, but DNS itself would have no issue with that. You could test it first by adding some test subdomain and different MX records for it. As for postfix, I'm not familiar with its config options. I'd say pass the address off to procmail, and in procmail you'd just have a recipe with "* ^X-Remote-Delivered-To: address" and the destination address/file/command on the next line. –  Jeremy M Dec 16 '10 at 2:03

I would use the Google Apps solution as mentioned above, but instead of fetchmail I would recommend taking a look at offlineimap. 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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.