Configure postfix to relay mails using SendGrid

To use postfix to send email using sendgrid, you first you need to install postfix on your server. Edit


Delete the line. Go to end of the file and add following

Create API Key in SendGrid

Next you need to create an API key in sendgrid. To do this, go to Settings > API Key.

SendGrid API key

Click “Create API Key” button.

Sendgrid create api key

For this test, i just give the new API key Full Access. On next page you will get API key. Copy it and keep it safe as you won’t be seeing it again.

sendgrid api key created

Now you have the API key, that you can use with postfix.

Add API Key to postfix

Edit file


Here is what i have

[email protected]:~# cat /etc/postfix/sasl_passwd
[]:587 apikey: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
[email protected]:~#

Now run

To test email, run