SendGrid

SendGrid is a cloud server for sending out e-mails.

Configuration

  • 25 - TLS/plain
  • 465 - SSL
  • 587 - TLS/plain

Sendgrid recommends using port 587.

SSMTP

mailhub=smtp.sendgrid.net:587
AuthUser=sendgridusername
AuthPass=sendgridpassword
UseSTARTTLS=YES

Postfix

Here are the lines for /etc/postfix/main.cf to use SendGrid as a relay host with TLS:

smtp_sasl_auth_enable = yes 
smtp_sasl_password_maps = static:yourSendgridUsername:yourSendgridPassword 
smtp_sasl_security_options = noanonymous 
smtp_tls_security_level = may 
header_size_limit = 4096000
relayhost = [smtp.sendgrid.net]:587

Make sure to restart Postfix once these changes are done.

/etc/init.d/postfix restart

Note: If you are getting no mechanism available error messages it generally indicates that you may be missing some SASL authentication libraries. In this case you may want to:

apt-get install libsasl2-modules

or on a Yum-based system:

yum install cyrus-sasl-plain

Local Mail

Setup Postfix to send local mail to itself.

Tell Postfix where the virtual file is. Add this to /etc/postfix/main.cf:

virtual_alias_maps = hash:/etc/postfix/virtual

Add entries in the virtual map file, /etc/postfix/virtual:

root root@localhost
ubuntu ubuntu@localhost

Setup Postfix to use the virtual file:

postmap /etc/postfix/virtual