Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 邮件:选项必须在人员之前_Linux_Email_Shell_Unix_Solaris - Fatal编程技术网

Linux 邮件:选项必须在人员之前

Linux 邮件:选项必须在人员之前,linux,email,shell,unix,solaris,Linux,Email,Shell,Unix,Solaris,我正试图通过使用邮件指定发件人选项来发送电子邮件 echo "This is the main body of the mail" | mail -s "Subject of the Email" recipent_address@example.com -- -f from_user@example.com 每当我尝试上面的命令时,我总是得到错误消息- mail: Options MUST PRECEDE persons 我没有收到任何电子邮件。为什么会这样 我正在运行SunOS bas

我正试图通过使用邮件指定发件人选项来发送电子邮件

echo "This is the main body of the mail" | mail -s "Subject of the Email" 
recipent_address@example.com -- -f from_user@example.com
每当我尝试上面的命令时,我总是得到错误消息-

mail: Options MUST PRECEDE persons
我没有收到任何电子邮件。为什么会这样

我正在运行
SunOS

bash-3.00$ uname -a
SunOS lvsaishdc3in0001 5.10 Generic_142901-02 i86pc i386 i86pc
编辑 你的标题表明了一件事,现在我看到你想要传递谁是发件人。根据下面手册页的引用,
-f
并不意味着
来自

为什么需要这样做,您的邮件客户端和sendmail将正确设置“发件人”标题?(请通过编辑您的问题来回答此问题,而不是作为下面的评论:-)

结束编辑

您收到错误消息的原因是,对于几乎所有的Unix命令(包括
mail
),使用
--
向程序(mail)指示“选项结束”

因此,您的
-f
将不会按预期进行处理。你为什么不这样做

echo "This is the main body of the mail" | mail -s "Subject of the Email" \
 -f from_user@example.com recipent_address@example.com 

对于我可以在网上找到的两个邮件(*)程序手册页,它们对
-f
选项的用途相似:

 -f [file]       Read messages from file instead of  mailbox.
                     If no file is specified, the mbox is used.
这就是你的意图吗?换句话说,你对
-f的使用user@example.com
似乎没有意义,除非您有这样命名的邮箱文件


IHTH

除了下面的答案之外,您可能希望使用
-r
,而不是
-f