Take the 2-minute tour ×

I want to use SendGrid as my email sending service, but want to also use Postfix's internal queue mechanism to manage the emails sent through Sendgrid.

So basically what I want to do is to configure Postfix to send emails through Sendgrid's SMTP, and I will configure my app to send the emails using the local Postfix.

My question is, how can I configure Postfix to use an external SMTP? Looked here but didn't see anything useful.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

This is detailed in http://www.postfix.org/BASIC_CONFIGURATION_README.html#relayhost

share|improve this answer
Thanks. I got about the same thing at docs.sendgrid.com/documentation/get-started/integrate/examples/… and I just needed to copy paste it and it worked. It's basically the same thing you said, so I'm going to accept your answer in about 5 minutes :) –  Eduard Luca Sep 10 '12 at 12:54

Looks like you got things figured out, but for future reference to anyone who's looking:

1) Edit your Postfix configuration file

Open up your /etc/postfix/main.cf config file and edit it to have the following values:

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

2) Restart your postfix server

Run the following command in your terminal

/etc/init.d/postfix restart

3) Start sending

You're all set, go ahead and start sending with your SendGrid account!

If you run into any issues, you can always ask our 24/7 support team or tweet at @SendGrid.

share|improve this answer
Exactly what I did. Very straight-forward :) Thanks! –  Eduard Luca Sep 11 '12 at 7:48
If submission to your service is always encrypted, you should use smtp_tls_security_level=encrypt. start_tls is not a postfix configuration setting; remove it. –  adaptr Sep 11 '12 at 14:40

Your Answer


