Search code examples
macosmacos-high-sierramsmtp

How to install and configure MSMTP on OSX?


Following the instructions on ArchLinux to install and configure msmtp does not work. The file /etc/ssl/certs/ca-certificates.crt or anything like it is missing, and trying to use msmtp to send mail will result in a certificate error.

What is an alternate configuration for OSX High Sierra so that msmtp can be used to send mail like in the tutorial?

Note: I answered this question for myself some time ago and decided it's useful and worth sharing, so I created this question and answer. It would be nice if someone with more knowledge of certificates and fingerprints could provide a higher quality answer with more detail and background information about the difference between using a certificate or a fingerprint, for example.

Note years later: I know it's a self answered Q/A but this has 1k views so maybe remember to upvote a useful Q/A.


Solution

  • An alternative method that works for me and avoids the issue of the tls_fingerprint expiring.

    Use MacPorts to install the curl CA bundle:

    sudo port install curl-ca-bundle

    Locate the bundle:

    port contents curl-ca-bundle
    
    Port curl-ca-bundle contains:
      /opt/local/etc/openssl/cert.pem
      /opt/local/share/curl/curl-ca-bundle.crt
    

    Add the following line to .msmptrc

    tls_trust_file /opt/local/share/curl/curl-ca-bundle.crt

    It works:

    Hatchet:~ me$ mail [email protected]
    Subject: Hi Mike
    done
    .
    EOT
    

    No error. From the log file:

    exitcode=EX_OK