
On 5/14/20 11:05 AM, Andrey Repin wrote:
Greetings, Robert Moskowitz!
If I user formail to -I replace the From-Header, formail creates a From-mbox line where the sender is foo@bar. That's the default if there's no valid From: in the incoming message. There IS a From: in the original message:
From: "(Cron Daemon)" <rgm> That's not a valid From: address since it doesn't have a domain name.
Ah, I will take your word for it. I could never grok 822. https://tools.ietf.org/html/rfc5322#section-3.4.1
It is what cron is doing, though. Why put something in broken? It could have done rgm@localhost. Which is about as "useful". I'd rather like <cron@`hostname --fqdn`>
Well I now have some results of my script and some things kind of work and others don't. #!/bin/sh [[ -z $MAILTO ]] && MAILTO=$USER FullName=$(getent passwd $MAILTO | cut -d: -f5) EmailAddr="$MAILTO@$HOSTNAME" [[ -z $FullName ]] || EmailAddr="$FullName <$EmailAddr>" formail -i "Date: $(date +'%a, %e %b %Y %T %z (%Z)')" -a Message-ID: \ -I "From: (Cron Daemon) <$USER@$HOSTNAME>" -I "To: $EmailAddr" \ | procmail -f $MAILTO For output of crontab entries (from my user crontab): From rgm Thu May 14 04:01:11 2020 Subject: Cron <rgm@lx140e> rsync -tvz rsync.tools.ietf.org::tools.id/*.txt /home/common/ietf/drafts MIME-Version: 1.0 . . . X-Cron-Env: <USER=rgm> Message-ID: <AK0hgwC4d1.A.yjE.MrPveB@lx140e.htt-consult.com> Date: Thu, 14 May 2020 04:01:11 -0400 (EDT) From: (Cron Daemon) <rgm@lx140e.htt-consult.com> To: Robert Moskowitz <rgm@lx140e.htt-consult.com> Status: RO The From, Date:, From:, and To: were added by formail. Well actually the From is from procmail, as formail was putting foo@bar in the From line. This is from cron which was putting out: From: "(Cron Daemon)" <rgm> To: rgm That looks OKish. I loose the "" around (Cron Daemon) as how would I put them into that formail command? But it messes things up with the output from logwatch. I "know" that logwatch generates: To: root From: logwatch my script replaces that with: From root Thu May 14 03:48:06 2020 Subject: Logwatch for lx140e.htt-consult.com (Linux) Auto-Submitted: auto-generated Precedence: bulk MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="UTF-8" Message-ID: <Rd8yDiB9CqC.A.pbE.7ePveB@lx140e.htt-consult.com> Date: Thu, 14 May 2020 03:48:06 -0400 (EDT) From: (Cron Daemon) <root@lx140e.htt-consult.com> To: root <root@lx140e.htt-consult.com> Ouch, I loose that the message is from logwatch, not just root! I have played around with formail, and I have not figured out how to pick up that the original From: is not USER Can someone help on this? thanks