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

user1@mydomain.com    user1@gmail.com
user2@mydomain.com    user2@gmail.com
office@mydomain.com   user1@gmail.com, user2@gmail.com, ...

Everything works fine, except that when I send mail from my user1@gmail.com GMail account to user1@mydomain.com, 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 office@mydomain.com 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 forward@mydomain.com) to prevent GMail from ignoring the mail.


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

  • Spammer sends spam to user1@mydomain.com
  • You forward it to user1@gmail.com
  • 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.


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.

  • 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. – Ryaner Jul 8 '14 at 22:30

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 example.user@gmail.com get's forwarded to this user's gmx address example2.user2@gmx.net using the sender address

    postfix/qmgr[740]: 123EBA6885: from=<example.user+caf_=example2.user2=gmx.net@gmail.com>, 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 example.user@gmail.com. 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.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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