Setup Alibaba Cloud ECS Server Cloud Postfix Email Using Sendgrid

By default Alibaba Cloud Block Out going port 25 . We need to setup smtp relay for it. We choose . Free account is available .

First register at choose free plan or buy plan from them .

Next We setup postfix in our centos 7.

yum -y install postfix cyrus-sasl-plain mailx

Postfix will need to be restarted before the SASL framework will be detected.

systemctl restart postfix
systemctl enable postfix
Open the /etc/postfix/ and add the following lines to the end of the file.
vi /etc/postfix/
add the configuration below
myhostname =
relayhost = []:587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_tls_CAfile = /etc/ssl/certs/ca-bundle.crt
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
Open /etc/postfix/sasl_passwd and add the configuration.
vi /etc/postfix/sasl_passwd
[]:587 username:password
To get the username and password above : go to

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
Lastly, reload the Postfix configuration.
systemctl restart postfix

Lastly test messages from mail to yourself and see /var/log/maillog

echo “This is a test.” | mail -s “test message”

tail -f /var/log/maillog

Leave a Reply

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