Updating the Postfix configuration to use SendGrid as a relay host is easy. For more advanced configuration scenarios, you’ll need to refer to the Postfix documentation.
Some implementations of Postfix only allow passwords to contain letters and numbers, meaning you may need to ensure your SendGrid password is only alphanumeric.
Find your Postfix config file, typically /etc/postfix/main.cf, and add the following:
1 2 3 4 5 6 7
Now you need to specify your credentials (optionally, use
apikey as username and an API Key as password) in the separate file /etc/postfix/sasl_passwd (you’ll likely need to create it):
Next, make sure the file has restricted read and write access only for root, and use the
postmap command to update Postfix’s hashtables to use this new file:
Finally, restart Postfix:
If you are getting no mechanism available error messages it generally indicates that you are missing some SASL authentication libraries.
Install the missing module dependency using apt-get (i.e., Debian, Ubuntu):
Or using a yum (i.e., RedHat, Fedora, CentOS):
If port 587 is not working for you please try 2525 in your postfix config. You may also need to edit /etc/postfix/master.cf to remove # from
#tlsmgr unix - - n 1000? 1 tlsmgr