I use msmtp as the sendmail program on my Ubuntu 18.04 system. Rather than have the password of smtp service sitting in the clear in my msmtprc file, I have written a small ruby program that I call "authinfo" that takes a hostname on the command line, finds its password in ~/.authinfo.gpg, decrypted it, and echos it to stdout.
This works great if I run msmtp from the command line.
However, when cron runs it to send email about a cron command, it fails, with the following in the log file:
Jul 16 16:01:01 micah CRON[19482]: (ded) CMD (bash -l -c 'env >&2 && exit 2')
Jul 16 16:01:05 micah cron[1486]: Cannot read from file '/.authinfo.gpg'.
Jul 16 16:01:05 micah cron[1486]: sendmail: cannot read output of '/home/ded/bin/authinfo smtp.gmail.com'
Jul 16 16:01:05 micah CRON[19481]: (ded) MAIL (mailed 1846 bytes of output but got status 0x004e from MTA#012)
It seems it cannot read the stdout of my authinfo program. This is different from a command run from the sixth field of a crontab command, which is affected by the SHELL and PATH environment settings in the crontab file. I', guessing the way sendmail is run is hard-coded into cron. Somehow, it is not letting sendmail/msmtp get the output of the passowrdeval program from the .msmtprc file.
Any ideas as to why?