Configure Linux Server (Ubuntu 16.04 LTS) to send email…

Setup and Configure SSMTP and MAILUTILS to send email from system, ie: alarm notification, crontab’s message…
This tools is useful that you do not need to setup a MTA (Mail Transfer Agent) like SMTP Server, Sendmail… to deliver system’s message.

root@ubuntu:~# sudo apt install ssmtp mailutils

root@ubuntu:~# cat /etc/ssmtp/ssmtp.conf
#--------------------------------------
#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=<ie: postmaster@infotechviet.com>

# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
#mailhub=mail
mailhub=<your email's servcer:port>
AuthUser=<your email's account>
AuthPass=<your email's password>
UseTLS=YES
UseSTARTTLS=YES

# Where will the mail seem to come from?
rewriteDomain=<ie: infotechviet.com>

# The full hostname
hostname=<ie: infotechviet.com>

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
FromLineOverride=YES
#--------------------------------------

Test sending an email:

root@ubuntu:~# echo "Hello, this is mail content for test" | mail -s "Hello test!!!" "info@infotechviet.com"

Tips:

Configure alias for root, or postmaster to forward system’s message to your expect email address.

root@ubuntu:~# vi /etc/ssmtp/revaliases
#----------------------------------------
#
# sSMTP aliases
# 
# Format:       local_account:outgoing_address:mailhub
#
# Example: root:your_login@your.domain:mailhub.your.domain[:port]
# where [:port] is an optional port number that defaults to 25.
root:nghiale@infotechviet.com
romano:nghiale@infotechviet.com
postmaster:nghiale@infotechviet.com
#
#----------------------------------------
root@ubuntu:~#
RELATED POSTS
Share the Post: