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(_dot_)A(_dot_)yjE(_dot_)MrPveB(_at_)lx140e(_dot_)htt-consult(_dot_)com>
Date: Thu, 14 May 2020 04:01:11 -0400 (EDT)
From: (Cron Daemon) <rgm(_at_)lx140e(_dot_)htt-consult(_dot_)com>
To: Robert Moskowitz <rgm(_at_)lx140e(_dot_)htt-consult(_dot_)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(_dot_)A(_dot_)pbE(_dot_)7ePveB(_at_)lx140e(_dot_)htt-consult(_dot_)com>
Date: Thu, 14 May 2020 03:48:06 -0400 (EDT)
From: (Cron Daemon) <root(_at_)lx140e(_dot_)htt-consult(_dot_)com>
To: root <root(_at_)lx140e(_dot_)htt-consult(_dot_)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
____________________________________________________________
procmail mailing list -- procmail(_at_)lists(_dot_)rwth-aachen(_dot_)de
Procmail homepage: http://www.procmail.org/
To unsubscribe send an email to
procmail-leave(_at_)lists(_dot_)rwth-aachen(_dot_)de
https://lists.rwth-aachen.de/postorius/lists/procmail.lists.rwth-aachen.de