You can configure Postfix MTA to use as a Smarthost i.e. routing all mails to a smarthost. A smarthost can be an external smtpd server provided by SendGrid, AWS, Rackspace, Google apps/Gmail, ISP or your own server in another data center with the help of the relay server.

sudo dpkg-reconfigure postfix

sudo nano /etc/postfix/

Set myhostname to FQDN

myhostname =

# Enable auth
smtp_sasl_auth_enable = yes
# Set username and password
smtp_sasl_security_options = noanonymous
# Turn on tls encryption 
smtp_tls_security_level = encrypt
header_size_limit = 4096000
# Set external SMTP relay host here IP or hostname accepted along with a port number. 
relayhost = [YOUR-SMTP-SERVER-IP-HERE]:587
# accept email from our web-server only 
inet_interfaces =

sudo systemctl stop postfix

sudo systemctl start postfix

Verify that TCP port #25 is in listing state on

sudo apt install net-tools

netstat -tulpn | grep :25

Send a test mail using Postfix the relay server:

echo "This is a test email body." | mail -s "Subject" -a "From:"

sudo tail -f /var/log/mail.log


root: $USER@websrv
sudo newaliases

hosts: websrv

Leave a Reply

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