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).
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,
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.
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,
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