Postfix forwarding to GMail address

6,490

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

Share:
6,490

Related videos on Youtube

martin
Author by

martin

Updated on September 18, 2022

Comments

  • martin
    martin almost 2 years

    I configured postfix to forward mail to external addresses (mostly GMail):

    [email protected]    [email protected]
    [email protected]    [email protected]
    [email protected]   [email protected], [email protected], ...
    ...
    

    Everything works fine, except that when I send mail from my [email protected] GMail account to [email protected], it gets forwarded (250 OK in the log), but never shows up in GMail. That's probably not a common scenario, but sending mail from my GMail account to [email protected] or putting myself in Cc is. I just don't like the idea of my message being lost without any sign of error.

    I plan to configure a forwarding for a few other users too and I'm sure everyone will first test it by sending a mail to himself (and then tell me, that it doesn't work).

    This issue has been discussed in a previous post:

    Forward Mails to Gmail

    1. Can anyone confirm the reason for that behavior?
    2. Does anyone know how other mail providers handle it (I only tested it with GMail so far).
    3. Any suggestions for a workaround?

    I know postfix can rewrite the header of a message. Could I just change the from-address in such a case (to something like [email protected]) to prevent GMail from ignoring the mail.

  • Ryaner
    Ryaner almost 10 years
    If the original mail is coming from gmail, then this is definitely what is happening. Gmail fingerprints the mails based on the headers to deduplicate them. Forwarders without any header modification can get caught by this.