Sunday, January 12, 2020

Use Postfix to Relay Mail Thru Godaddy SMTP Servers

How to Install and Configure Postfix to Relay Thru Godaddy SMTP

postfix logo
postfix logo
If you have an Asterisk server on Amazon ECS, you need a means to send voicemails out to email. Use postfix with a godaddy smtp server and your godaddy email credentials.

First you need to install ubuntu on an amazon ecs virtual machine. Start by setting up their free tier ubuntu 18 LTS server.  Then you need to use apt-get to install postfix and mailutils.

To install the required items:

apt install postfix
apt install mailutils
apt install cyrus-sasl-plain

Finally install some configuration files. First file to work on is /etc/postfix/
suppose your server is called and your domain is called   Do not change the default hostname that amazon ecs gives you.  While installing postfix, the initial dialog will ask you what kind of site to setup. Choose "internet site" you will only be using this service to send and relay outbound email.

# See /usr/share/postfix/ for a commented, more complete version

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
readme_directory = no
compatibility_level = 2

# TLS parameters
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
masquerade_domains =
myhostname =
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = $mydomain
mydomain =
mydestination =, $myhostname, ip-172-16-17-0.ec2.internal, localhost.ec2.internal, localhost
relayhost =
mynetworks = [::ffff:]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = loopback-only
inet_protocols = all

# use godaddy smtp as a relay
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_wrappermode = yes
smtp_tls_security_level = encrypt
smtp_tls_mandatory_protocols = TLSv1
smtp_tls_mandatory_ciphers = high
smtp_tls_secure_cert_match = nexthop
smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt
relayhost =

## THIS ITEM: append_dot_domain will take the domain from /etc/mailname and set your from name
append_dot_mydomain = no
# --> Setting it to yes appends the domain to the hostname

# get CA bundles

Next You need to enter your Godaddy SMTP credentials in the file called sasl_password

Next you need to hash the file up with this command
postmap hash:/etc/postfix/sasl_passwd

Next we need to test it out with sendmail. send a message to

root@ip-172-16-17-0:/etc/postfix# /usr/sbin/sendmail -F "MIKE Martin" -f
subject: This is a test of Postfix again
Hello There This is how we test postfix using the sendmail command == bye


Some Useful Tidbits of Information

reload and force a re-read of config files:  postfix reload
restart the service:  /etc/init.d/postfix reload
see the log files: more /var/log/mail.log

Known Postfix bugs

root@ip-172-16-17-0:/etc/postfix# postconf -d myhostname
myhostname = ip-172-16-17-0.localdomain
even if you set myhostname in to something else, you still get this.

If you install ssmtp, it will delete the sendmail command and softlink it to ssmtp instead.

1 comment: