How to Send Email With Postfix on Ubuntu via Gmail SMTP

|

I just setup email sending on my server by following this clear tutorial.

The tutorial walked me through setting up Postfix on an Ubuntu server and sending email via Gmail’s SMTP. I had to create a certificate, sign it, have my server communicate via some secure transport layer with Gmail using another certificate signed by some country in South Africa. I don’t understand all of it, but it works.

If you have WordPress installed like me, you can test Postfix is working by asking for a password reset on the wp-admin screen. You should get an email right away.

If you notice this error in your mail log:

localhost postfix/smtp[18542]: certificate verification failed for aspmx.l.google.com[74.125.113.27]:25: untrusted issuer /C=US/O=Equifax/OU=Equifax Secure Certificate Authority

You can fix that by following this blog post. But I wouldn’t recommend copying the digital certificates on that site (or any site for that matter). Copy/paste the appropriate certificates stored in your server. If you’re using Ubuntu, they can be found in /usr/lib/ssl/certs.

If you notice this error:

localhost postfix/tlsmgr[18877]: warning: request to update table btree:/var/run/smtpd_tls_session_cache in non-postfix directory /var/run
localhost postfix/tlsmgr[18877]: warning: redirecting the request to postfix-owned data_directory /var/lib/postfix
localhost postfix/tlsmgr[18877]: warning: request to update table btree:/var/run/smtp_tls_session_cache in non-postfix directory /var/run
localhost postfix/tlsmgr[18877]: warning: redirecting the request to postfix-owned data_directory /var/lib/postfix

Replace those two instances of /var/run in the Postfix main.cf with /var/lib/postfix.