You are here

Postfix, Google Apps, MX Records, and Relay

I have a Cent OS dedicated virtual server with Postfix. I also have google apps on a local domain.

When using any local applications, like PHP, to send email it will try to look up the host locally and deliver the mail internally rather than utilizing the google apps domain.

For example. A php script utilizes mail to send to Postfix sees that is hosted on the same server. However, is hosted at google apps. Postfix will return an error saying 'unknown user'.

It's very simple to resolve this issue. You do not need to relay off of google apps SMTP servers.

Edit the following file (I like to use nano)

nano /etc/postfix/

Update your transport maps if it's not set. I have Plesk installed as well, so I added hash:/etc/postfix/transport before hash:/var/spool/postfix/plesk/transport separated by a comma.

transport_maps = hash:/etc/postfix/transport, hash:/var/spool/postfix/plesk/transport

If you have made the MX changes to your domain for google apps , make the following addition in your /etc/postfix/transport file.

nano /etc/postfix/transport

It'll force postfix to look at your MX records rather than trying to deliver the mail internally. If you use brackets [] around in the relay it will ignore MX records (e.g. relay:[], which is good if you have your mail server locally to prevent loopbacks, but we are using google apps).

Run the following command to hash your transport file.

postmap /etc/postfix/transport

Reload your postfix configuration

postfix reload

Try sending mail and see what your results are. This is my mail log location:

tail -50 /usr/local/psa/var/log/maillog

You should see something like this:

Nov 18 00:00:00 fit postfix/smtp[3212]: 91B149F99213: to=<>, relay=ASPMX.L.GOOGLE.COM[]:25, delay=1.2, delays=0.04/0/0.28/0.84, dsn=2.0.0, status=sent (250 2.0.0 OK)

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer