Forums/Official SendGrid/FAQ: Getting Started

Getting Started: Configuring Postfix

Joe Scharf
posted this on April 08, 2010 11:55

It is recommended to queue the mail locally before sending it to SendGrid so that your web application instantly returns to the user generating the emails. Postfix will then forward the emails to SendGrid on the background and automatically retry in case of any problems.

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

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 with /etc/init.d/postfix restart

Here are the lines for /etc/postfix/main.cf to use SendGrid as a relay host (unencrypted connection)

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

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
 

Comments

User photo
Sendgrid

Thanks Joe,

I installed cyrus-sasl-plain but still getting the same "no mechanism found" error in my maillog.

any other usual suspects?

 

B8BA65F8797: to=<xxxxxx@gmail.com>, relay=none, delay=0.03, delays=0.02/0.01/0/0, dsn=4.7.0, status=deferred (delivery temporarily suspended: SASL authentication failed; cannot authenticate to server smtp.sendgrid.net[174.36.32.204]: no mechanism available)

July 05, 2011 12:24.
User photo
Sendgrid

Nevermind.. I was trying something fancy with my password_maps option..

the static: one from your doc works fine, thanks much.

July 05, 2011 12:48.