How to install ssmtp under Slackware

The ssmtp program is a small ''SMTP'' server that only forwards a system email to an existing mail box on an existing server.

That program is ideal when you'd like to be able to send mail, without having to install or configure the sendmail Slackware package (which can be a massive pain in the neck, let's face it).

So: how to install ssmtp?

1. How to install ssmtp.

Download ssmtp from its home page:

Make sure you download the ''orig'' package, and not the Debian one!

Now if you try to compile the program right away, you will probably end up with the following error:

gil:~$ ./configure --enable-logfile --enable-ssl --enable-md5auth ; make all ; sudo make install
gcc -o ssmtp ssmtp.o arpadate.o base64.o xgethostname.o md5auth/md5c.o md5auth/hmac_md5.o -lnsl \
"/usr/local/etc/ssmtp\" -DCONFIGURATION_FILE=\"/usr/local/etc/ssmtp/ssmtp.conf\" -DREVALIASES_FILE=\ \
"/usr/local/etc/ssmtp/revaliases\"  -g -O2 -Wall
/usr/lib64/gcc/x86_64-slackware-linux/4.7.1/../../../../x86_64-slackware-linux/bin/ld: ssmtp.o: undefined reference to symbol 'X509_free'
/usr/lib64/gcc/x86_64-slackware-linux/4.7.1/../../../../x86_64-slackware-linux/bin/ld: note: 'X509_free' is defined \
in DSO /lib64/ so try adding it to the linker command line
/lib64/ could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
make: *** [ssmtp] Error 1

Here is the proper procedure to compile it:

First run the configure command as follows:

gil:~$ ./configure --enable-logfile --enable-ssl --enable-md5auth

Next, edit the Makefile and replace:

$(CC) -o ssmtp $(OBJS) -lnsl  -lssl $(CFLAGS)

With the following:

$(CC) -o ssmtp $(OBJS) -lnsl  -lssl -lcrypto $(CFLAGS)

Now, run the usual:

gil:~$ make ; sudo make install-sendmail

(Please note the install-sendmail directive)

And you are done!

2. Configure ssmtp.

The program ssmtp on its own is not very useful. Let's make it send system emails to a Google Mail account.

First, let's make some symbolic link to make sure ssmtp replaces sendmail on our machine:

root:~# ln -s --verbose /usr/local/sbin/ssmtp /usr/bin/sendmail
'/usr/bin/sendmail' -> '/usr/local/sbin/ssmtp'

root:~# ln -s --verbose /usr/local/sbin/ssmtp /usr/sbin/sendmail
'/usr/sbin/sendmail' -> '/usr/local/sbin/ssmtp'

root:~# ln -v -s /usr/local/etc/ssmtp/ /etc/ssmtp
'/etc/ssmtp' -> '/usr/local/etc/ssmtp/'

Oh, look, there is a sendmail installed now!

root:~# which sendmail

root:~# ll $(which sendmail)
lrwxrwxrwx 1 root root 5 Jan 10 14:48 /usr/local/sbin/sendmail -> ssmtp*

Good, now edit /etc/ssmtp/ssmtp.conf and put the following in:

# /etc/ssmtp.conf -- a config file for sSMTP sendmail.
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
# The place where the mail goes. The actual machine name is required
# no MX records are consulted. Commonly mailhosts are named
# The example will fit if you are in and you mailhub is so named.
# Where will the mail seem to come from?
# The full hostname
# --------------------------------------------------------
# Authentication
# --------------------------------------------------------
# --------------------------------------------------------
# Ref. :
# --------------------------------------------------------

Add this to the /etc/ssmtp/revaliases file:

# 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.

Send yourself a mail... And you should be in business!

For instance, if you entered the connection information correctly, the following command should work:

gil:~$ echo "This is a test message from: $(hostname)." | mailx -s "[TEST] $(uname -n) $(date)" 

Pat yourself on the back: your system can now send email through Gmail! Cool!

See Also: