Saturday, March 7, 2009

/bin/mail and setting the From: line

UNIX geekery ahead. Skip to save your sanity.

Over the years I've needed a script to set the From: line in a mail that it sends out - and the syntax is quite obscure and doesn't always turn up in a Goolgle search.

So what you need is to give mail the -- argument which lets you pass arguments straight to sendmail:


echo "message body" | mail -s "subject" user@domain.tld -- -F "Users Name" -f user2@domain.tld

No comments: