Best practices for forwarding mail to Gmail

If you're forwarding mail to Gmail, you may want to ensure that mail will be correctly classified by the Gmail spam filter. Check out the sections below for tips on how to optimize Gmail's spam-filtering capabilities.

If you're a mail server administrator:

Ownership and Filtering

We recommend that you do not change the envelope sender when forwarding email to Gmail. Sometimes, when forwarding email, the envelope sender gets changed to your domain. When this happens, Gmail may learn that your domain is sending spam, and will treat other emails from this domain as spam as well. Are you using procmail for forwarding?

Please note that procmail is one of the most common reasons why the envelope sender gets changed when forwarding. Adding the following to your config file will fix this issue:

SENDER=`formail -c -x Return-Path`

SENDMAILFLAGS="-oi -f $SENDER"

Alternatively, changing the envelope sender is ok if you do one of the following:

  • Put "SPAM" in the subject
  • OR discard any spam emails and not forward them to Gmail at all.

SpamAssassin is a free spam filter that can be used for identifying spam outside of Gmail, and putting "SPAM" in the subject.

Authentication

  • Do not modify, remove or shuffle message headers or modify the body of the message. DKIM or DomainKeys signatures will break if the body is altered, and all authentication information will be lost.
  • Common DKIM breakages include modifying the mime boundaries, anti-virus or anti-spam programs modifying the body of the message, expanding the message recipient using LDAP, and re-encoding the message.
  • Several highly-phished domains have asked Gmail to enforce strict authentication checks on their mail. These domains include eBay, Paypal, and Google. If your mail server modifies the forwarded messages from these domains, these messages will be marked as phishing.
  • One symptom of this problem is that a messages from these domains forwarded through your mail server to Gmail will have an Authentication-Results header that show that DKIM did not pass, while messages sent directly to Gmail will have a passing signature.
  • If you're not a mail server administrator, but use your mail provider's forwarding services:

  • We recommend modifying your forwarding settings to ensure that spam is not forwarded to Gmail. If you are unable to modify your forwarding settings, we recommend contacting the administrator of your mail service provider for further instructions.
  • Go to your Mail settings and Accounts tab and add the address you are forwarding from to 'Send mail as'. This is a new feature from user requests, where Gmail will detect that you forwarded from that account and help prevent displaying a phishing warning.