From ArchWiki
Revision as of 16:10, 5 July 2010 by Misc (talk | contribs) (Test msmtp)
Jump to navigation Jump to search

msmtp is a very simple and easy to use smtp client with excellent sendmail compatibility.


Template:Package Official is in the extra repository.

# pacman -S msmtp

Quick start

The following is an example of a msmtp configuration file for several accounts. If msmtp throws errors when using this file, search for double byte '\xc2\xa0' characters that may have been erroneously inserted. Template:File

msmtp will refuse to start if the file is readable and writeable to anyone else but the owner:

$ chmod 600 ~/.msmtprc

Test msmtp

The Template:Codeline flag specifies the account to use as sender; Template:Codeline is the recipient.

Save (with your own mail addresses)

To: <username>
Subject: A test

Yadda, yadda, yadda.

as, say, "test.mail".

Then execute

$ cat test.mail | msmtp -a default <username>


Practical password management

The Template:Codeline directive may be omitted. In that case, if the account in question has Template:Codeline set to a legitimate value other than Template:Codeline, invoking msmtp from an interactive shell will ask for the password before sending mail. msmtp will not prompt if it has been called by another type of application, such as Mutt.

If this is not desired, an alternative is to place passwords in Template:Filename, a file that can act as a common pool for msmtp, OfflineIMAP, and associated tools.

Using msmtp offline

Note: The msmtp source distribution includes msmtpq and msmtpQ in the ./scripts directory, which are updated versions of the msmtpqueue bundle.

Although msmtp is great, it requires that you be online to use it. This isn't ideal for people on laptops with intermittent connections to the Internet or dialup users. Several scripts have been written to remedy this fact, collectively called msmtpqueue.

The scripts can be downloaded from SourceForge, the most recent of which is msmtpqueue-0.5.tar.gz.

Once the scripts have been downloaded extract them using:

$ tar xf msmtpqueue-0.5.tar.gz

After that, copy the scripts to a convenient location on your computer (Template:Filename is a good choice):

$ cp msmtpqueue-0.5/*.sh /usr/local/bin/

Finally, change your MUA to use instead of msmtp when sending e-mail. Queued messages will be stored in Template:Filename.

When you want to send any mail that you've created and queued up run:

$ /usr/local/bin/

Adding Template:Filename to your PATH can save you some keystrokes if you're doing it manually. The README file that comes with the scripts has some handy information, reading it is recommended.

Vim syntax highlighting

The msmtp source distribution includes a Template:Filename highlighting script for Vim. Install it from Template:Filename.


Issues with TLS

If you see the following message:

 msmtp: TLS certificate verification failed: the certificate hasn't got a known issuer

it probably means your tls_trust_file is not right.

Just follow the fine manual. It explains you how to find out the server certificate issuer of a given smtp server. Then you can explore the Template:Filename directory to find out if by any chance, the certificate you need is there. If not, you will have to get the certificate on your own.

If you are completely deseperate, but are 100% sure you are communicating with the right server, you can always temporarily disable the cert check:

$ msmtp --tls-certcheck off