I am trying to send an email by specifying the from option using mail.
echo "This is the main body of the mail" | mail -s "Subject of the Email"
recipent_address@example.com -- -f from_user@example.com
Whenever I try the above command I always get error as-
mail: Options MUST PRECEDE persons
And I didn’t get any emails. Why is it so?
And I am running SunOS
bash-3.00$ uname -a
SunOS lvsaishdc3in0001 5.10 Generic_142901-02 i86pc i386 i86pc
EDIT
Your title indicates one thing, now I see you want to pass in who the sender is. Per quote from man page below,
-fdoesn’t meanfrom.Why do you need to do this, your mail client and sendmail will properly set your ‘from’ header? (and please answer this by editing your question, not as a comment below 🙂 ).
end edit
The reason you’re getting the error message that you do get is that for almost all Unix commands (including
mail) using--indicates to the program (mail) ‘END OF OPTIONS’.So your
-fwill not be processed as you expect. Why don’t you do???
For the two mail(*) programs I could find man-pages for online, they both have similar use for the
-foption:So is that what you intend? And, to put it another way, your use of
-f user@example.comdoesn’t seem to make sense unless you have mailbox files named like that.IHTH