Specify the from user when sending email using the mail command Specify the from user when sending email using the mail command linux linux

Specify the from user when sending email using the mail command


You can specify any extra header you may need with -a

$mail -s "Some random subject" -a "From: some@mail.tld" to@mail.tld


http://www.mindspill.org/962 seems to have a solution.

Essentially:

echo "This is the main body of the mail" | mail -s "Subject of the Email" recipent_address@example.com -- -f from_user@example.com


mail -r from@from.from -R from@from.com

-r = from-addr-R = reply-to addr

The author has indicated his version of mail doesn't support this flag. But if you have a version that does this works fine.