I am able to send mail from bash, but cannot change the from text, it currently comes up as 'root'.
I would like email clients to show the following text in the from field script on myserver.com ([email protected])
.
How can I do this please?
emailsubject="$scriptname ($scriptver) log at $startdate"
if [ $errorcount > 0 ]; then
emailsubject="ERRORS($errorcount) - ${emailsubject}"
fi
mail -s "$emailsubject" [email protected] < $logfile
If Your "mail" supports it, You may add custom headers using the -a switch like this:
mail -s "subject" -a "From: [email protected]" ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With