Change “from” address in Terminal `mail`

command lineemailterminal

When sending mail from shell, e.g.,

echo '123' | mail -s 'subject' name@mail.com

The recipient gets an email from "my-local-username@my-machine-name.local", e.g., "bob@macbook.local"

How can I change this to an email address of my choosing?

Best Answer

Tack an escape to the end of your mail command to pass a header to sendmail.

 -- -f not-bob@address.com

See this answer and others that use the -- terminator to tell the mail program those arguments are for the next program.

Related Question