Skip to content

Instantly share code, notes, and snippets.

@wnasich
Last active March 23, 2022 16:52
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wnasich/71093e406c07ed3f03f63da8abd6ce97 to your computer and use it in GitHub Desktop.
Save wnasich/71093e406c07ed3f03f63da8abd6ce97 to your computer and use it in GitHub Desktop.
Install outgoing email from Debian/Ubuntu system through SendGrid
$ sudo apt install postfix mailutils
# Choose host type 'No configuration'
$ sudo cp /usr/share/postfix/main.cf.debian /etc/postfix/main.cf
$ sudo vi /etc/postfix/main.cf
# Add lines below
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = static:apikey:paste_your_key_here
smtp_sasl_security_options = noanonymous
smtp_tls_security_level = encrypt
header_size_limit = 4096000
relayhost = [smtp.sendgrid.net]:587
# Redirect root emails to real email address
$ sudo vi /etc/aliases
root: [host]_postfix@[your domain]
$ sudo service postfix restart
# Check logs
$ tail -f /var/log/mail.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment