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 main.cf

Find

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.

https://app.sendgrid.com/settings/api_keys

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 SendGrid.com API key, that you can use with postfix.

Add API Key to postfix

Edit file

Add

Here is what i have

root@honVm:~# cat /etc/postfix/sasl_passwd
[smtp.sendgrid.net]:587 apikey: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
root@honVm:~#

Now run

To test email, run

Need help with Linux Server or WordPress? We can help!

Leave a Reply

Your email address will not be published. Required fields are marked *