Join us on Discord! We now have an official Discord server for OpenFLIXR: https://discord.gg/PcCErTQ , these forums will continue to operate as normal.

[Guide] Relaying Postfix emails via smtp.gmail.com

I credit most of this to the original author at https://easyengine.io/tutorials/linux/ubuntu-postfix-gmail-smtp/

I've used this solution on my physical Plex server box for years. I actually setup applications on pushover.net and foward emails to the pushover app on my phone. See this for help with that... http://updates.pushover.net/post/144473611422/new-e-mail-gateway-features

Install required packages

sudo apt install postfix mailutils libsasl2-2 ca-certificates libsasl2-modules

 Edit postfix config file…

vim /etc/postfix/main.cf

 Comment out or remove the following lines…

#default_transport = error
#relay_transport = error

 Add the following lines…

relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_use_tls = yes

 Create a file with Gmail credentials…

vim /etc/postfix/sasl_passwd

 Add this..

[smtp.gmail.com]:587    USERNAME@gmail.com:PASSWORD

 If you use two-factor authentication you will need to create an app password here…

https://security.google.com/settings/security/apppasswords

 Fix permissions & update postfix config…

sudo chmod 400 /etc/postfix/sasl_passwd
sudo postmap /etc/postfix/sasl_passwd

 Validate certicates…

cat /etc/ssl/certs/thawte_Primary_Root_CA.pem | sudo tee -a /etc/postfix/cacert.pem

 Reload postfix…

sudo /etc/init.d/postfix reload

 Test…

echo "Test mail from postfix" | mail -s "Test Postfix" you@example.com

 Now that we have forwarding working let's create some aliases…

vim /etc/aliases

 Change the root alias to…

root:     you@example.com

 Update aliases

newaliases

Test…

echo "Alias
test mail from postfix" | mail -s "Test alias" root

Comments

  • Thanks Brandon! Excellent guide. 
    Did you test it against OpenFLIXR 1.5.0? Because I added postfix to that version with local only config. 
  • Yes,  I believe you are referring to the inet_interfaces=looopback-only option which only refers to incoming emails not outgoing. But yes I I'm running 1.5.0, even the html formatted emails from netdata.io are showing up in my Pushover app formatted correctly. Now if I can just figure out why I'm dropping so many packets :/ sda1 full after hours notfications are a bit aggressive too I think.
  • Adding openflixr.openflixr to mydestination= in the /etc/postfix/main.cf then 'sudo postfix reload' will avoid undeliverable messages.
Sign In or Register to comment.