Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change sender name (not email address) when using the linux mail command for autosending mail? [closed]

Mailbox shows the sender name as "Apache", because the mail I am autosending is being sent from a Perl CGI program. How do I change it to something else?

like image 253
therobyouknow Avatar asked Jun 30 '11 15:06

therobyouknow


People also ask

How do I specify an address from an email in Linux?

Some Linux distributions link to mailx where you can use the -r from-addr parameter. If you have mutt you should be able to use mutt -e "set from='name <name@somewhere>'> . Other distributions which have the mail command should be able to use echo "test"|mail -s "subject" [email protected] -- -f from@address .

How do I change my address in mailx Linux?

You can use the "-r" option to set the sender address: mailx -r [email protected] -s ... This is troubling for me because the man page of mailx says: "-r address Sets the From address. Overrides any from variable specified in environment or startup files.


1 Answers

You just need to add a From: header. By default there is none.

echo "Test" | mail -a "From: Someone <[email protected]>" [email protected] 

You can add any custom headers using -a:

echo "Test" | mail -a "From: Someone <[email protected]>" \                    -a "Subject: This is a test" \                    -a "X-Custom-Header: yes" [email protected] 
like image 105
sam hocevar Avatar answered Sep 19 '22 10:09

sam hocevar