Alibaba Cloud Centos 8 / RHEL 8 Configuring Postfix Mail Server With SendGrid Relay , SPF .

First Create Account At https://sendgrid.com/

  1. Next Go to Email Api –> Integration Guide
  2. Choose SMTP RELAY .
  3. Enter Your Choosen Api Key than press Create

Setting UP postfix

yum -y install postfix cyrus-sasl-plain mailx

yum -y install postfix cyrus-sasl-plain mailx
systemctl enable postfix

Edit /etc/postfix/main.cf

vi /etc/postfix/main.cf

find and replace this

inet_interfaces = all

Press Shift + G and add this line to the bottom

relayhost = [smtp.sendgrid.net]:587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous

Open /etc/postfix/sasl_passwd and add the configuration. To get the username and password https://app.sendgrid.com/guide/integrate/langs/smtp

vi /etc/postfix/sasl_passwd

[smtp.sendgrid.net]:587 username:password

A Postfix lookup table must now be generated from the sasl_passwd text file by running the following command.

postmap /etc/postfix/sasl_passwd

Access to the sasl_passwd files should be restricted.

chown root:postfix /etc/postfix/sasl_passwd
chmod 640 /etc/postfix/sasl_passwd

Test Mail Using Mail

echo “This is a test.” | mail -s “test message” user@example.net
tail -f /var/log/maillog

In order that Our Email is place properly not in Spam Folder , We need to configure SPF , DKIM and DMARC

The following methods authenticate your email and prove to the inbox providers that your email is worthy of the inbox and not the spam folder:

Configure SPF For Postfix

First add MX record to Our DNS record , example Our domain is dodocrypto.com add MX Record For it , Next Add TXT Dns Record with this value v=spf1 mx ~all

Check Our New Domain SPF https://dmarcian.com/spf-survey/

Leave a Reply

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