EDIT
Your title indicates one thing, now I see you want to pass in who the sender is. Per quote from man page below, -f
doesn't mean from
.
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 -f
will not be processed as you expect. Why don't you do
echo "This is the main body of the mail" | mail -s "Subject of the Email" \
-f from_user@example.com recipent_address@example.com
???
For the two mail(*) programs I could find man-pages for online, they both have similar use for the -f
option:
-f [file] Read messages from file instead of mailbox.
If no file is specified, the mbox is used.
So is that what you intend? And, to put it another way, your use of -f user@example.com
doesn't seem to make sense unless you have mailbox files named like that.
IHTH