Relaying Outbound Mail Through Gmail

Tom J Nowell edited this page Feb 4, 2018 · 5 revisions


Note: These are old instructions for VVV 1, and will not work in VVV 2+. For the latest documentation see here

By default many receiving mail servers will reject messages sent from a VVV vhost because the sending domain is not a valid FQDN. Relaying outbound messages through Gmail solves that problem, and can also help avoid the message mistakenly being flagged as spam.

Note: MailCatcher is configured in VVV and can be accessed at http://vvv.test:1080/

  1. Redirect php to use sendmail instead of mailcatcher: replace sendmail path pointing to mailcatcher with sendmail_path = "/usr/sbin/sendmail -t -i" in mailcatcher.ini used for php configuration

  2. sudo nano /etc/postfix/ and replace the relayhost = line with these:

    relayhost = []:587
    smtp_sasl_auth_enable = yes
    smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
    smtp_sasl_security_options = noanonymous
    smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
    smtp_use_tls = yes

  3. sudo nano /etc/postfix/sasl_passwd and add this line


  4. sudo chmod 400 /etc/postfix/sasl_passwd

  5. sudo postmap /etc/postfix/sasl_passwd

  6. sudo /etc/init.d/postfix reload

  7. Test that everything works by using the Lost your password? link on http://local.wordpress.test/wp-login.php or, on a more low-level by running echo "Subject: test" | /usr/lib/sendmail -v

  8. If you don't receive the message, run tail -n 30 /var/log/mail.log to inspect the logs

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.