6

I've been trying to send mail with msmtp with no success

Configuration file: ~/.msmtprc

defaults
auth           on
tls            on
tls_trust_file /etc/ssl/certs/ca-bundle.crt
logfile        ~/.msmtp.log

account iisr
host smtp.yandex.com
port 465
user [email protected]
from [email protected]
password ********

when testing it with the command echo "hello there username." | msmtp -a iisr [email protected], no results at all, neither in the log file,

using the script by @Andrezj in the answer below I get the following output and it stays like this:

ignoring system configuration file /etc/msmtprc: No such file or directory
loaded user configuration file /home/bakenoor/.msmtprc
using account iisr from /home/bakenoor/.msmtprc
host                  = smtp.yandex.com
port                  = 465
timeout               = off
protocol              = smtp
domain                = localhost
auth                  = choose
user                  = [email protected]
password              = *
passwordeval          = (not set)
ntlmdomain            = (not set)
tls                   = on
tls_starttls          = on
tls_trust_file        = /etc/ssl/certs/ca-bundle.crt
tls_crl_file          = (not set)
tls_fingerprint       = (not set)
tls_key_file          = (not set)
tls_cert_file         = (not set)
tls_certcheck         = on
tls_force_sslv3       = off
tls_min_dh_prime_bits = (not set)
tls_priorities        = (not set)
auto_from             = off
maildomain            = (not set)
from                  = [email protected]
dsn_notify            = (not set)
dsn_return            = (not set)
keepbcc               = off
logfile               = /home/bakenoor/.msmtp.log
syslog                = (not set)
aliases               = (not set)
reading recipients from the command line and the mail

any idea why the mail is not being sent ?

1
  • 5
    My configuration for smtps (port 465) works with tls_starttls off.
    – AnFi
    Jan 24, 2015 at 17:55

2 Answers 2

5

Configuration

For SMTP port 465, ensure the Start TLS option is off in the $HOME/.msmtprc file:

defaults
auth           on
tls            on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile        /tmp/msmtp.log

account        ACCOUNT
host           mail.host.com
port           465
from           [email protected]
user           [email protected]
password       PASSWORD
tls_starttls   off

account default : ACCOUNT

Also ensure the file permissions are restricted to the user:

chmod 600 $HOME/.msmtprc

Debugging msmtp email sending

Use the following test script to get full transcript of SMTP session

#!/bin/sh
# msmtp specific options
# -d : debug
# -a : account name
# sendmail compatibility options
# -i : ignored for sendmail capability
# -t : Read recipient addresses from the To, Cc, and Bcc headers 
msmtp -d -a iisr -i -t <<END
From: [email protected]
To: [email protected]
Subject: test

test
END

Related

For details, see the following:

0
1

On CentOS 7.3 behind a firewall, My /etc/msmtprc:

defaults
logfile /var/log/msmtp.log
domain localhost
auth on
port 465
host smtp.gmail.com
tls on
tls_starttls off
auth on
tls_trust_file /etc/ssl/certs/ca-bundle.crt
# gmail account
account workflow
user *[email protected]*
from *[email protected]*
password *mypassword*
# set default account to use
account default : workflow
2
  • 1
    Are you suggesting this is the solution to the problem? With the scant explanation, it's difficult to tell exactly what you're trying to say. Jan 13, 2018 at 0:58
  • I was able to get it to work with the above configuration, so yes, it's my solution. Sorry about not being clear. Also, to note, I used the alternatives command to setup msmtp as the default for sending mail. Initially msmtp wasn't in the mta list, but I made the modification described here: bugzilla.redhat.com/show_bug.cgi?id=1367858 so msmtp would appear in the list. Jan 16, 2018 at 20:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .