On 01/12/12 09:32:11, Chris Purves wrote:
> On Thu, 29 Nov 2012 21:39:32 -0400, Chris Purves wrote:
>> I'm having problems with the output of cron jobs. cron sets the From
>> header as root, but does not include the domain. My email is then
>> rejected because it doesn't include a proper email address in the
>> From header.
<snip>
It's because of the From header. The envelope-from is fine. The
message I receive is:
'550 No verifiable sender address in message headers'
I've been sitting on the sidelines waiting for one of the msmtp gurus to
give you the definitive answer.
I have just looked up one of my ancient scripts that used msmtp to send
attachments (msmtp was the easiest lightweight way to do so from a script).
First, don't ask cron to do too much -- it doesn't like it. Just point
cron at a shell script.
The rest is done in your shell script (or whatever).
Secondly, create a dummy msmtp runcontrol file with one section
[Default]. Give the dummy file 600 permissions. Delete it at the end of
the script.
Thirdly, at the commencement of your message create a few additional
headers [Date, From, Sender, Reply-To, Message-ID, etc.], being careful
to have no blank lines before or between the additional headers and one
blank line after them.
Then have your script execute:
msmtp --file=/tmp/dummy/msmtp/runcontrol/file -- "recipient" < "$MESSAGE"
Because msmtp is a well behaved MTA it works out that the first part of
the message is additional headers and treats them accordingly. I found,
and still do find, that the combination of all the header information
and the "additional" headers at the beginning of the message works for me.