MSMTP says the email is queued but never get's sent

December 31, 2014 5.5k views

I installed MSMTP as my mail client on my Ubuntu LAMP on 14.04 droplet. I followed a tutorial and managed to get PHP using it to send mail. Testing via Wordpress works beautifully.

I've got it setup to use Mandrill to send mail. I can view the Mandrill logs as well as the Droplet logs at /var/log/msmtp.log.

Now I'm trying to get cron to use msmtp to send it's notifications. The first step was to verify my user could send mail via the command line. Well, that's where I've got stuck. Using this command:

echo -e "Subject: Test Mail\r\n\r\nThis is a test mail" | msmtp --debug --from=default -t

I see the log come into my msmtp.log file, and everything is reported as OK. I even get a queued number, something like:

Dec 31 03:56:50 tls=on auth=on from=default mailsize=40 smtpstatus=250 smtpmsg='250 2.0.0 Ok: queued as E467F1C02F5' exitcode=EX_OK

But this never get's to Mandrill. Well from what I can tell it doesn't.

Can anyone help me get through the first step of sending mail from the cmd line?

  • Does the mail command not work?

    echo "This is the contents of the mail" | mail -s "Test Mail"
  • Hi gndo, here's the output:

    ➜  ~  echo "This is the contents of the mail" | mail -s "Test Mail"
    msmtp: no recipients found
    mail: Sending data to /usr/bin/msmtp failed: Process exited with a non-zero status
    mail: cannot send message: Process exited with a non-zero status
  • I'm having exactly the same problem. The SMTP session with Mandrill reports '250 2.0.0 Ok: queued as 36269462067', but mail never appears in Mandrill or gets delivered, and exactly the same output from the mail command.

    I think tried installing bsd-mailx but it fails, and with less useful debug information.

2 Answers

If you go into the API Logs on mandrill's web site and search for "Mandrill-Python" you will see only the SMTP messages in the API Log.

looking at the Full Response section will give you some clues.
When I was struggling with this I was seeing an error like this:

    "reject_reason": "invalid-sender"

Make sure you include the from address as the first line of your mail message.

echo -e "\r\nSubject: Test Mail\r\n\r\nThis is a test mail" | msmtp --debug --from=default -t

If you remove the "--from=default" it should work. This is because:

  1. The receiving smtp server is rejecting the "default" address from the command line.
  2. Even though you remove the "--from=default" msmtp will read the default block (if you don't specify any) from the user (or system) config.
Have another answer? Share your knowledge.