I recently configured my own postfix mail system on a VPS I have. I didn’t want to host any mail locally so configured the mail daemon in such a way that it forwards all mail it receives to an externally hosted mail account – in this case gmail. This is frequently configured in a file named /etc/postfix/virtual with the following format:
@yourdomain.com [email protected]
Where @yourdomain.com is the postfix mail system you are configuring and [email protected] is the account the mail will be forwarded to. I went to test this system and found some odd behaviour when sending to this new email account from the same gmail account the forwarder was to. It seems that gmail uses some sort of routing loop detection which will prevent a mail being sent, and then received back on the same account when it doesn’t know about this forwarder.
Mar 10 07:59:49 reticent postfix/smtp: 5F3E61F240461: to=<[email protected]>, orig_to=<[email protected]>, relay=gmail-smtp-in.l.google.com[2a00:1450:4013:c01::1a]:25, delay=0.87, delays=0.33/0/0.11/0.42, dsn=2.0.0, status=sent (250 2.0.0 OK 1394438389 n7si32545975eeu.187 – gsmtp)
Despite giving us the ‘thumbs up’ that the mail has been delivered with a 250 code (universal for everythings OK) this mail seemingly disappears into a black hole. It cannot be found anywhere in the recipient inbox, spam folders, trash etc. Mail sent by other systems, like hotmail / yahoo etc to this account work fine. It will also work from other gmail accounts (just not the one the forwarder is sending to). I often forward mail to myself to read later, so this is one way I could run into this issue if I was using that new domain.
In order to fix this, it seems that you need to make the gmail system aware that this forwarder exists. You can do this by adding an alias to your gmail account under Settings / Accounts and Import / Send Mail As. Click “Add another email address you own” and add this alias you have created or intent on using, ie [email protected]
There is still a limitation in that only some of the aliases on your domain will work, and not the whole wildcard. Ie by adding the above [email protected] will work, but bo[email protected] won’t. It’s a bit annoying that you cant add this whole domain if the whole domain is indeed forwarded to a gmail account.