Configure Postfix Relay with Google Apps

 

Recommended Configuration (Google Apps paid accounts)

If you are using a paid version of Google Apps, and you would like to avoid Google rewriting the sender, you must first configure your Google Apps account for IP-based relay by following these instructions to allow relay from your server’s public IP address by any email addresses.

After Google Apps has been configured to allow relay from your server’s public IP address, you may configure postfix with:

relayhost = [smtp-relay.gmail.com]

Alternative Configuration (Google Apps free accounts, Gmail)

The correct SMTP server configuration for the free version of Google Apps and Gmail is:

relayhost = [smtp.gmail.com]:587

Please note that Google will automatically rewrite the sender (FROM) address to match whichever account is used for SMTP authentication (i.e. if you authenticate with eclipse@domain.com, all emails will appear to be sent from that address, regardless of which from address is specified in Eclipse). This is a limitation enforced on Google’s end, so there is no way around this on the Linux server side, other than to use a paid version of Google Apps (please see above) or use a mail relay service like SendGrid.