8

I am trying to setup Ubuntu 20.04 with msmtp as a system configuration.

I installed msmtp (v1.8.6-1) and heirloom-mailx (v12.5-2+deb7u1build0.14.04.1).

Config file /etc/msmtprc (chmod: 600) has the following:

# Set default values for all accounts.
account default
auth           on
tls            on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile        /var/log/msmtp

# gmail
host           smtp.gmail.com
port           587
from           <account>@gmail.com
user           <account>
password       <password>

# Syslog logging with facility LOG_MAIL instead of the default LOG_USER
syslog LOG_MAIL

Log file /var/log/msmtp file mode is 660.

File /etc/mailrc (chmod: 600) contains the following:

set sendmail="/usr/bin/msmtp"

When I try to use sendmail to send an email from terminal I get the following sendmail: account default not found: no configuration file available.

The same error comes up if I directly invoke msmtp.

AnFi
  • 872
  • 5
  • 13
chribonn
  • 271
  • 1
  • 2
  • 12

1 Answers1

11

Warning 1 : My advise is based on Debian msmtp package.
Warning 2 : Newer msmtp packages no longer install msmtp as set group id for security reasons.

Recommended Fix: Make /etc/msmtprc owned by group msmtp.

chown root:msmtp /etc/msmtprc
chmod 640 /etc/msmtprc

Explanation: msmtp binary is installed as set group (msmtp) id

$ ls -l /usr/bin/msmtp
-rwxr-sr-x 1 root msmtp 139000 Aug 20 16:24 /usr/bin/msmtp
AnFi
  • 872
  • 5
  • 13
  • 1
    This works on Raspbian buster as well! – Jason Thrasher Dec 08 '20 at 03:31
  • chown: invalid group: ‘root:msmtp’ – iHad 169 Jul 10 '21 at 00:16
  • Check explanation. 1) Is /usr/bin/msmtp installed as set **group** id? 2) Is it owned by group other than msmtp? **ANYWAY**: It seem to work on **some** version of distributions. If it does not work for your name distribution version you use and provide version of msmtp pacjage you installed. – AnFi Jul 10 '21 at 10:38