Eric Guo's

Hoping writing JS, Ruby & Rails and Go article, but fallback to DevOps note

Building a Postfix Satellite SMTP Service to Avoid Active Mailer Run in Aliyun


Some situation is better avoid Sidekiq like reporting the exception mail, so it’s always the best practices to building a Postfix Satellite SMTP service instead.

Install Postfix

yum install -y postfix cyrus-sasl-plain # cyrus-sasl-plain is no need for Ubuntu
yum erase -y sendmail* # In case Sendmail is installed


Similar to gmail or SendGrid, every mail service vendor offer different combination of setting, below is only apply to AliYun

/etc/postfix/ change

# comment out below
#inet_interfaces = localhost
relayhost = []:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CApath = /etc/ssl/certs
smtp_use_tls = yes
smtp_generic_maps = hash:/etc/postfix/generic
mynetworks =
mydestination =

Create /etc/postfix/sasl_passwd


Create /etc/postfix/generic

Create a database file

postmap /etc/postfix/sasl_passwd /etc/postfix/generic

Prevent non-root access:

chmod 0600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db /etc/postfix/generic /etc/postfix/generic.db

Restart Postfix service

/etc/init.d/postfix restart # or service postfix restart


It’s very common that postfix will failed to sent mail at first time, so add below to

debug_peer_level = 3
debug_peer_list =

And open another console to testing via:

echo "body of your email" | mail -s 'mail subject from console' -r ''

You may also need postconf -n to review postfix configuration or postconf -d to review all setting.

YOu can also monitor the postfix activity via tail -f /var/log/syslog.