procmail
[Top] [All Lists]

Re: How can I use command line formail to change From and To headers

2020-05-11 21:36:45


On 5/11/20 8:50 PM, Robert Moskowitz wrote:
I am working with the output from cron.  The From: and To: headers are like:

From: "(Cron Daemon)" <rgm>
To: rgm

Where the string rgm is from the cron env MAILTO, which is unavailable outside of cron (typically it is set to USER).

What I want to change them to is:

From: "(Cron Daemon)" <rgm@$HOSTNAME>
To: rgm@$HOSTNAME

I tried the -R option, but I am not using it right, as it does not seem to change anything:

formail -R $USER $USER@$HOSTNAME  >> mailfile < cronout

Is this possible and how?

I think I have got it with some help:

formail -i "Date: $(date +'%a, %e %b %Y %T %z (%Z)')" -a Message-ID: -I "From: (Cron Daemon) <$USER@$HOSTNAME>" -I "To: $USER@$HOSTNAME" -s procmail

This assumes that the cron env MAILTO==USER

Too bad there is not an env var for the full user name.



____________________________________________________________
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

<Prev in Thread] Current Thread [Next in Thread>