NexentaCore 3.0.1 is not configured out of the box to send mails through smtp.

All I want is to get notification mails from the NexentaCore box in case of failures etc., problem is I have to use an external smtp-server.

Being not a *nix guy I didn’t want to mess with sendmail / postfix / whatever.

Information on the web is very limited, so it was most trial & error to find an easy solution. At last I’m now a happy msmtp user. Big kuddos to fedoraswiss and his blog post which at last got me up & running.

Here are my steps to get it working on NexentaCore 3.0.1:

#First install the msmtp package

$ apt-get install msmtp

Note: As of today the msmtp package in the repository is rather old (1.4.13 in opposite to the official version 1.4.23) and lacks some features, f.e. „–tls-fingerprint“.

Create a config for msmtp, either globally or per-user. The following example is per-user, must be named „.msmtprc“ and placed in the users home folder:

$ cd ~
$ nano .msmtprc

.mstmprc’s content:

#Specify log path
logfile ~/.msmtp.log
tls on
account myaccount
host smtp.yourdomain.tld
from sender@yourdomain.tld
#my smtp server issues a cert with a different name, so I need to get rid of this
tls_certcheck off
tls_starttls on
auth on
user username
password your_secret_password

account default : myaccount

#smtp refuses to work if the rights on the .msmtprc file are not correct

$ chmod 600 ~/.msmtprc

To ease sending mails from the commandline (f.e. with cron) one can pipe mailx through msmtp. I do this because I didn’t find a satisfying way to enter the whole message on the commandline directly with msmtp. Specifying a file containing the message body is not an option for me.

Create or modify the file ~./mailrc to include the line

set sendmail="/usr/bin/msmtp"

Now you can send mails like this:

$ echo "this is the message body" | mailx -s "this is the subject line" receiver@somedomain.tld

Hinterlasse eine Antwort