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

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


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

echo "Test" | mail -a "From: Someone <someone@example.com>" other@example.com

You can add any custom headers using -a:

echo "Test" | mail -a "From: Someone <someone@example.com>" \                   -a "Subject: This is a test" \                   -a "X-Custom-Header: yes" other@example.com


mail -s "$(echo -e "This is the subject\nFrom: Paula <johny@paula.com>\nReply-to: 1232564@yourserver.com\nContent-Type: text/html\n")" milas.josh@gmail.com < htmlFileMessage.txt

the above is my solution..just replace the "Paula" with any name you want e.g Johny Bravo..any extra headers can be added just after the from and before the reply to...just make sure you know your headers syntax before adding them....this worked perfectly for me.


You can use the "-r" option to set the sender address:

mail -r me@example.com -s ...

In case you also want to include your real name in the from-field, you can use the following format

mail -r "me@example.com (My Name)" -s "My Subject" ...