3

msmtp is successfully installed and works fine to send emails via an external SMTP server.

However the mail command fails to send emails using GNU Mailutils on a Debian 10.

for example

echo "Test" | mail [email protected]

returns

mail: cannot send message: Process exited with a non-zero status

and

echo $? 

returns "36"

I'm supposing this is a msmtp is not integrating with the mail command. How do I configure mail to send messages through msmtp?

EDIT: The programs seem to be communicating because the keyring prompt pops up and the login options are set only in ~/.msmtprc

JBC
  • 51
  • 1
  • 4
  • There are different software packages offering a mail command. Can you please add information about which one you are using. – Mathias Weidner Mar 21 '21 at 09:46
  • 1
    @MathiasWeidner Wasn't aware, thanks for calling out. It's GNU Mailutils. Edited the question. – JBC Mar 21 '21 at 10:43

2 Answers2

2

This worked

From https://moritzvd.com/email-with-smtp-debian-ubuntu/

In order to be able to use the mail command wee need to install mailx

sudo apt-get install bsd-mailx

Set mail transport agent to use msmtp

sudo nano /etc/mail.rc

append the following:

set mta=/usr/bin/msmtp

JBC
  • 51
  • 1
  • 4
  • Thanks, I tried installing `s-nail` which still didn't provide the `mail` command. Your suggestion worked. – MrCarrot Jun 01 '21 at 07:36
0

You probably have to configure the mailer statement in the config file as is explained in the manual. Either use a statement like sendmail://progname if msmtp adheres to sendmail compatibility or use something like prog://pathname[?query] as is explained on this page.

How you can find the global or local config file is also explained in the manual. It is usually /etc/mailutils.config for the global config file or ~/.mail for the local config file.

Mathias Weidner
  • 669
  • 4
  • 10
  • Config files are to be found nowhere. The commands in the manual do not return any results, and they are not on the suggested locations. The programs seem to be communicating because the keyring prompt pops up and the login options are set only in ~/.msmtprc Editing question again. Could not find the log files either. – JBC Mar 21 '21 at 21:56
  • edit: The log files are there but show no update once I removed postfix (it was overkill for this project). – JBC Mar 21 '21 at 22:03
  • It might be an issue with msmtp-mta, but it's hard to find documentation on that. https://wiki.debian.org/msmtp – JBC Mar 21 '21 at 22:13
  • You can look with `strings $(which mail)` what filename is compiled in. On an Ubuntu 18.04 I am using, the local config file seems to be *~/.mailrc*. – Mathias Weidner Mar 21 '21 at 22:14
  • This worked From https://moritzvd.com/email-with-smtp-debian-ubuntu/ In order to be able to use the mail command wee need to install mailx sudo apt-get install bsd-mailx Set mail transport agent to use msmtp sudo nano /etc/mail.rc append the following: set mta=/usr/bin/msmtp – JBC Apr 04 '21 at 22:26