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

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

2 Answers 2

3

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

1
  • Thanks, I tried installing s-nail which still didn't provide the mail command. Your suggestion worked.
    – MrCarrot
    Commented Jun 1, 2021 at 7: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.

6
  • 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
    Commented Mar 21, 2021 at 21:56
  • edit: The log files are there but show no update once I removed postfix (it was overkill for this project).
    – JBC
    Commented Mar 21, 2021 at 22:03
  • It might be an issue with msmtp-mta, but it's hard to find documentation on that. wiki.debian.org/msmtp
    – JBC
    Commented Mar 21, 2021 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. Commented Mar 21, 2021 at 22:14
  • This worked From 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
    Commented Apr 4, 2021 at 22:26

You must log in to answer this question.

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