#569122 $HOME/.msmtprc is incompatible with vixie cron.

Package:
msmtp
Source:
msmtp
Description:
light SMTP client with support for server profiles
Submitter:
Austin Clements
Date:
2017-09-24 13:03:04 UTC
Severity:
wishlist
#569122#5
Date:
2010-02-10 07:38:59 UTC
From:
To:
vixie-cron runs /usr/sbin/sendmail with the HOME environment variable
set to /.  Because msmtp looks for per-user configuration in
$HOME/.msmtp, it will fail to find the configuration file of the user
cron is sending mail on behalf of.  On a system that depends on
per-user configuration files, this makes cron incapable of sending
mail as any user (including root).

This problem manifests itself in the syslog as something like
  Feb 10 01:18:01 drake /USR/SBIN/CRON[26100]: (root) MAIL (mailed 8 bytes of output but got status 0x004e )
and, in fact, if you mimic how cron runs sendmail
  HOME=/ /usr/sbin/sendmail -i -FCronDaemon -oem amd...@mit.edu
sendmail (msmtp) immediately exits with
  sendmail: account default not found: no configuration file available
and exit code 78 (0x4e).

It's entirely possible this should also be considered a bug in cron.
I reported it against msmtp because it is an incompatibility with
sendmail that can easily be rectified (by retrieving the user's home
directory from the password database instead of relying on HOME to
have a sane value).

#569122#10
Date:
2010-02-10 21:25:40 UTC
From:
To:
Hi Austin,
file: /etc/msmtprc

You can generate it with: dpkg-reconfigure -plow msmtp

For me msmtp-mta (with a correct setup in /etc/msmtprc) works perfectly
with cron.


Unless you disagree, i will close this bug.


Regards,

#569122#15
Date:
2010-02-10 22:58:04 UTC
From:
To:
Thanks for the quick reply.

I'm aware of this.  Perhaps my bug should have been "per-user
configuration is incompatible with vixie cron".  Personally, I'm
unwilling to put sensitive information in a world-readable file.
Furthermore, people shouldn't be prohibited from using per-user
configuration files simply because they're running msmtp from cron.

That being said, the more I look into this, the more I feel this is
really a cron bug.  msmtp's logic is to use the value of HOME, if set,
and to fall back on the password database otherwise.  This seems
utterly reasonable.  On the other hand, cron's setting of HOME
violates convention and expectation, suggesting that cron is the poor
player here.

It would be nice if this incompatibility, its cause, and the potential
workaround you mentioned were at least documented.  There's abundant
evidence that I'm not the only one who has sunk hours of their life
into figuring out why cron and msmtp don't play nicely.

#569122#20
Date:
2010-02-14 22:36:23 UTC
From:
To:
Thanks for clarification.
I agree that it's not a msmtp bug and you should submit this feature
request to the multiple vixie-cron's compatible programs developers.
As a workaround it could be possible to use a wrapper in your own
crontabs.

exemple:
--8<---------
* * * * * mywrapper.sh my_command --option1 --option2
--------->8--

This wrapper will run 'my_command --option1 --option2' and catch
stderr/stdout and the return code to pipe them (if necessary) to msmtp.
Hence it will be possible to use your own msmtp configuration.

Regards,

#569122#29
Date:
2017-09-24 13:00:13 UTC
From:
To:
control: severity -1 wishlist

I think this old bug report is not really valid any more with recent
msmtp I tested.

Now we have -C option for msmtp, user doesn't need to rely on $HOME.  So
not even wrapper script is needed.  In that sense, this is not even a
bug.

But as a user support pointer, I just downgraded severity and keep this
bug here with hints

Osamu