Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save akeemoduola/57f825fa52dea20276113ef4cbb9cfb7 to your computer and use it in GitHub Desktop.
Save akeemoduola/57f825fa52dea20276113ef4cbb9cfb7 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