The Quick-N-Dirty Guide to ssmtp

The aim of this QND guide is to get you up and running quickly with ssmtp. There will be far more how than why here.

The ssmtp program is designed to be a substitute for sendmail (or postfix, exim and other heavy duty MTA’s) for people who need an external smtp program to send mail, such as those who use mutt. While it is slightly more complex and heavy than nbsmtp (no brainer smtp) it is a bit more efficient, writes to /var/log/maillog and has a few nice features.

1.) Do you have ssmtp?

I don’t know of any Linux distro or other *nix system that installs ssmtp by default. However, it never hurts to check. At a command line type

which ssmtp

If you get a response like /usr/bin/ssmtp or /usr/local/sbin/ssmtp, you can skip to step 3. Otherwise, continue with step 2.

2.)Installing

First follow the instructions in the QND software guide for information on getting and installing ssmtp. If it’s not included with your distribution (while it is in Gentoo’s portage and FreeBSD’s ports, it doesn’t seem to be on any of the RedHat 8.0 CD’s) then go to the homepage. They have a tar.gz file.

3.)Installing ssmtp

FreeBSD’s ports or Gentoo’s portage will install ssmtp for you. If you’ve downloaded the tarball then untar it somewhere and install it in the more or less usual way. This will have to be done as root or with root privilege.

tar -zxvf ssmtp*tar.gz
cd ssmtp*
./configure
make
make install

4.)Configuring ssmtp

The ssmtp program will install either a sample conf file or the actual file in /usr/etc or perhaps /usr/local/etc, depending upon distribution. This file will have to be edited slightly to make it work. Some of the comments in the file can be a bit misleading. I am including an entire file from a FreeBSD installation, with the hope that it will be clearer where you have to make changes. I am typing in ALLCAPS above the lines that you will have to change.

#
# /etc/ssmtp.conf -- a config file for sSMTP sendmail.
#
# The person who gets all mail for userids < 1000
root=postmaster
# The place where the mail goes. The actual machine name is required
# no MX records are consulted. Commonly mailhosts are named mail.domain.com
# The example will fit if you are in domain.com and your mailhub is so named.
CHANGE THE LINE BELOW
mailhub=mail
# Example for SMTP port number 2525
# mailhub=mail.your.domain:2525
# Example for SMTP port number 25 (Standard/RFC)
# mailhub=mail.your.domain
# Example for SSL encrypted connection
# mailhub=mail.your.domain:465
# Where will the mail seem to come from?
THIS LINE WILL HAVE TO BE EDITED
rewriteDomain=
# The full hostname
THE BELOW LINE WILL HAVE TO BE CHANGED
hostname=
# Set this to never rewrite the "From:" line (unless not given) and to
# use that address in the "from line" of the envelope.
THE LINE BELOW SHOULD BE UNCOMMENTED
#FromLineOverride=YES
# Use SSL/TLS to send secure messages to server.
#UseTLS=YES
# Use SSL/TLS certificate to authenticate against smtp host.
#UseTLSCert=YES
# Use this RSA certificate.
#TLSCert=/usr/local/etc/ssmtp/ssmtp.pem

For our example, we’ll assume that your isp is called isp.com and their smtp server is smtp.isp.com. The local hostname is john.john.com The first line to be changed is the one marked mailhub=mail In our case, with an smtp server called smtp.isp.com it should be changed to read

mailhub=smtp.isp.com

Next, we cover the line that reads rewriteDomain=
Using our example of having an isp called isp.com it should be changed to read

rewriteDomain=isp.com

In other words, the domain of your isp, eg mindspring.com or whatever. Next, the hostname. The line that reads hostname should be changed to the local hostname.

hostname=john.john.com

The last change to be made is in the line that says FromLineOverride=YES. Many people, (judging from google) including myself, found that line a bit confusing. If you don’t uncomment it (by removing the # sign) you may find that all your mail comes from User &. So, uncomment it.

5.) Testing ssmtp

To test ssmtp, try sending an email. You can send one to yourself, and make sure you get it, or elsewhere. You can also look at /var/log/maillog which should show that the mail was sent successfully.