Mutt + TLS + SASL using the sSMTP MTA - HOWTO

My setup

I already had this setup up and running correctly:

The problem

The problem arised when I had to talk to a new SMTP server which required both SSL encryption (TLS) and user authentication.

Email clients like Mozilla, MS Outlook, Netscape already implement this feature, but I wanted to keep using Mutt (if you don't know why, stop reading here).

Patching postfix to talk to the SMTP server seemed too much pain (I tried, but couldn't get it to work, others may have been more successful), so the solution had to pass thorugh a change of MTA (Mail Transport Agent).

sSMTP

  1. Get ssmtp (version 2.48 worked for me)
  2. Configure it to enable TLS: ./configure --enable-ssl
  3. The file net.c requied some patching:

    After patching, net.c (line #30) looks like:

    #ifdef HAVE_SSL
    SSL *ssl;
    extern Bool UseTLS;
    extern Bool UseTLSCert;
    extern char *TLSCert;
    #endif
    
  4. Build and install: make, and make install
  5. Configure properly and verify that you are connecting to the right port : normal SMTP is port 25, encrypted SMTP (SMTPS) is port 465

Mutt's private config file (.muttrc)

Simply change the MTA using ssmtp:

set sendmail="/path/to/ssmtp -au username -ap password"