How to configure sending mail from Linux – easy way

I have spent some time to configure sendmail on Linux server in order to send mail trough our MS Exchange 2007. All was good, email has been sent but never delivered as the MS Exchange server was refusing to deliver and failed every time. Sendmail is great if you are able to configure it and it works 😉 I spent so much time on Internet, reading man pages and even the book — no go 🙁

. . .

It was  depressing to have so many troubles with such simple task. All has been resolved today. I have found way easier way to do this and it works out of the box with few lines of modifying. It is very simple and fast and you can be up and running under 2 minutes.

I have found this great utility called ssmtp

It works under Debain, Centos, FreeBSD … and it is virtually simple to configure. I have it installed on Debian

apt-get install ssmtp

Once installed you will find two conf files under

cd /etc/ssmtp
revaliases ssmtp.conf

I have hosting for domain (MYDOMAIN.COM) with 1and1 and their smtp server is using port 587. I have created email as and here is how I configured it in the ssmtp.conf file

# Config file for sSMTP sendmail
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
# root=postmaster

# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named

# Where will the mail seem to come from?

# The full hostname

# 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

Once you have edited the file, save it and try to send email, for example I will try to get listing of directory and send it to me

ls -l | mail -s "DIRECTORY LISTING"

If all went fine you should get your email with the directory listing in few seconds to your email ( That is it, was simple and it works ! You can even easily configure ssmtp to send email via Google smtp server. All works and now I am getting my system emails as expected 😉 Let me know in comments if you have troubles to configure it.

Leave a Reply