mailx change sender name

拜拜、爱过 提交于 2019-12-22 06:48:02

问题


I understood that for changing sender's name with mailx I should do the following:

mailx -r newmail@mail.com -s "some subject" my@email.com

But when I do that, I get:

mailx: invalid option -- r
Usage: mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...
            [-- sendmail-options ...]
       mail [-iInNv] -f [name]
       mail [-iInNv] [-u user

Does anyone knows what's happening? thanks,


回答1:


The correct syntax is:

mailx -s "some subject" my@email.com -- -r newmail@mail.com

The Usage info shows "[-- sendmail-options ...]" and since "-r" is a sendmail option, you need to use the double dashes first.




回答2:


mailx -a 'From:name@your-domain.com' -s "Subject" my-best-friend@other-domain.com < text.txt



回答3:


Tested with this and found to be working:

echo test | mailx -s "Mail Test" user@recipentdomain.com -- -f user@senderdomain.com

The double-dash before "-f" makes the mailx not to parse the -f, but only pass it to sendmail/postfix, which will then send with the "from" address mentioned.



来源:https://stackoverflow.com/questions/14607503/mailx-change-sender-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!