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

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? thanks

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.
participants (1)
-
Robert Moskowitz