Is there a way to modify the from user when using the mail command to send email? I looked over the man page and couldn’t figure out how to accomplish it.
Redhat Linux 5 is the operating system we’re using.
Asked by Joel Cunningham
With -a, you can specify any additional headers you require.
$mail -s "Some random subject" -a "From: email@example.com" firstname.lastname@example.org
Answered by daniels
There appears to be a solution at http://www.mindspill.org/962.
| mail -s “Subject of the Email” echo “This is the main body of the email” recipent email@example.com from firstname.lastname@example.org — -f
Answered by Paolo Bergantino
email@example.com mail -r -R firstname.lastname@example.org -R email@example.com -R from@from.
from-addr = from-addr -R stands for reply-to address.
The author has said that this flag is not supported by his version of mail. However, if you have a version that does, this will work perfectly.
Answered by bfabry
When sending over SMTP, the mail man page advises to set the from variable, in this way (Tested on CentOS 6):
mail -s Subject -S firstname.lastname@example.org email@example.com
You might alternatively use the -a option to attach a file:
mail -s Subject -S firstname.lastname@example.org -a path_to_attachement email@example.com
Answered by G.J
None of these worked for me (Ubuntu 12.04), but after some trial and error, I was able to get:
echo 'my message blabla\nSecond line (optional of course)' | mail -s "Your message title" -r 'Your full name<yourSenderAdress@yourDomain.abc>' -Sreplyto="yourReplyAdressIfDifferent@domain.abc" destinatorEmail@destDomain.abc[,otherDestinator@otherDomain.abc]
(all on one line, no space between “-Sreplyto” and “-Sreplyto”)
This mail command came from:
apt-get install mailutils
Answered by Le Droid
Post is based on https://stackoverflow.com/questions/119390/specify-the-from-user-when-sending-email-using-the-mail-command