Postfix forwarding to GMail address

Solution 1:

Top tip: just don't do this. It won't take long, then you'll have this situation:

  • Spammer sends spam to [email protected]
  • You forward it to [email protected]
  • GMail sees spam from you and adds you to their list of people who send spam
  • You don't get to send any mail to GMail any more until you change what you're doing

I've been there and done that. In fairness, there's no way they can tell for sure that you're not the person actually originating the spam. There'll be a bunch of extra Received headers in the mail, but you could fake those.

The other thing: SPF checks done by GMail will fail. Someone sends mail from (say) serverfault.com, you forward it to GMail, GMail checks serverfault.com's SPF record to see if your mail server is allowed to send mail for that domain, finds out it's not and drops your mail on the floor.

The correct way to do this is to keep the mail locally and have GMail pick it up via POP. GMail then knows that you're not the original sender, doesn't apply its spam checks in the same way and doesn't have the same problem with SPF.

Solution 2:

This is actually a Gmail feature, A message sent from GMail that is (somehow) forwarded back to the sending account is considered a duplicate, and does not show up in the inbox. I don't think it's documented anywhere, but it appears to have been discussed on Gmail support forums.

Solution 3:

I'm trying to do something similar and have no solution right now but maybe my researches help you.

Before I started to decide how my mailserver should do the mail forwarding I thought it's a good idea to have a look how the big mail provider realize mail forwarding.

For example gmail changes the sender (from in the envelope) in a very special way:

In the postfix mail.log you only see envelope Information (RCPT TO, MAIL FROM).

Mail sent to a gmail account with the address [email protected] get's forwarded to this user's gmx address [email protected] using the sender address

    postfix/qmgr[740]: 123EBA6885: from=<[email protected]>, size=4986, nrcpt=1 (queue active)

The receiving Mailserver can see that the mail is sent from a host that is allowed to sent mails for users with the address [email protected]. The plus separates the real sender in an encoded form. [This kind of mail extension can be defined in recipient_delimiter in Postfix's main.cf]

In this way the receiving mailserver could not only see that sender host is allowed to send this mail but on the other hand the original sender can be evaluated and compared with the mail header "From".

Some mailserver make trouble if the From header and the envelope Sender (Mail From) are different.

If someone knows a way how postfix can do forwarding like this I would like to know.

Regards

Martin