Does anyone know how to change the from user when sending email using the mail command? I have looked through the man page and can not see how to do this.
We are running Redhat Linux 5.
Does anyone know how to change the from user when sending email using the mail command? I have looked through the man page and can not see how to do this.
We are running Redhat Linux 5.
You can specify any extra header you may need with -a
I faced the same issue. But i solved the problem just be setting geko field in /ect/passwd field. Postfix by default send the mail from user login. Lets suppose you want to change from field to Alert. You just need to edit /ect/passwd file in any editor you like.
root:x:0:0:Alerts:/root:/bin/bash
Now check the result.
Now in recipient. From will be shown as Alerts as you have specified in geko field. Hope this solution works for you.
When sending over SMTP, the
mail
man page advises to set thefrom
variable, in this way (Tested on CentOS 6):You could also attach a file using the
-a
option: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.