Most Linux distributions install programs like Sendmail or Postfix to handle local mail deliveries. While this works fine on multi-user systems or servers, these programs are quite large and complex for single-user desktop systems. For Linux machines with a single user, the use of more lightweight mail “servers” may be desired: programs like sSMTP or eSMTP. eSMTP allows per-user configuration files unlike other similar programs, and so it’s useful even for multi-user systems.

eSMTP is packaged in some distributions so may be easily installed using urpmi, apt, or yum. If not, it is trivial to install although it does require the libESMTP library. If your chosen Linux distribution does not provide a binary copy of eSMTP, download the latest version of libESMTP (1.0.4) and eSMTP (0.6.0) and compile and install them using:

$ tar xvjf libesmtp-1.0.4.tar.bz2
$ cd libesmtp-1.0.4
$ ./configure --prefix=/usr/local
$ make
$ sudo make install
$ cd ..
$ tar xvjf esmtp-0.6.0.tar.bz2
$ cd esmtp-0.6.0
$ ./configure --prefix=/usr/local --with-libesmtp=/usr/local
$ make
$ sudo make install

The resulting libESMTP libraries will be installed in /usr/local, as will the esmtp program. Configuration for esmtp is done via the ~/.esmtprc file.

The ~/.esmtprc configuration file is very straightforward. A very basic one may look like:

hostname =
username = "joe"
password = "secret"
starttls = enabled
mda "/usr/bin/procmail -d %T"

This defines the server to which to send mail (the mail hub) — on port 25 with the username “joe” and the password “secret.” It also enables the STARTTLS extension. Finally, it defines the local mail delivery agent, procmail.

If you use multiple accounts, you can also tell eSMTP to use multiple SMTP servers dependent upon which account you are sending mail from by using the “identity” keyword:

    username "joe"
    password "secret"
    starttls enabled
    username ""
    password "secret2"
    starttls required
mda "/usr/bin/procmail -d %T"

eSMTP determines which server to use with the envelope sender flag, which is the –f option to Sendmail and similar MTA’s. For mail clients such as Mutt, this can be set with the set envelope_from=yes configuration option. Likewise, the path to Sendmail should be defined as /usr/local/bin/esmtp. For other mail clients, simply telling them to use the local Sendmail and pointing the path to /usr/local/bin/esmtp should be sufficient. If you’re unable to define the path to Sendmail, you can also opt to change /usr/lib/sendmail to a symlink pointing to /usr/local/bin/esmtp.

Finally, eSMTP can use the STARTTLS extension, but in order for it to do so, you need to add the root certificate of the CA that signed the server’s SSL certificate. eSMTP looks for this information in the ~/.authenticate/ directory. For simplicity, simply download the Mozilla bundle of CA root certificates into this directory; an appropriate bundle suitable for eSMTP can be obtained from the cURL Web site.

$ mkdir ~/.authenticate
$ chmod 0700 ~/.authenticate
$ curl >~/.authenticate/ca.pem
$ chmod 0600 ~/.authenticate/ca.pem

With all of this complete, you can use eSMTP to relay mail to an upstream provider SMTP service with ease, without worrying about configuring local Sendmail or Postfix services, which can be especially useful for mail clients with limited or no support for remote SMTP servers.

Get the PDF version of this tip here.

Delivered each Tuesday, TechRepublic’s free Linux and Open Source newsletter provides tips, articles, and other resources to help you hone your Linux skills. Automatically sign up today!