使用 bash 更改 sendmail 发件人

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7436944/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 21:02:04  来源:igfitidea点击:

Change sendmail sender using bash

bashsendmail

提问by ztank1013

Running the sendmail command I usually get emails with sender like username@hostname.

运行 sendmail 命令我通常会收到像username@hostname.

Is there a way to send emails using sendmail and having the sender set to something different from the user account used to run the command?

有没有办法使用 sendmail 发送电子邮件并将发件人设置为与用于运行命令的用户帐户不同的内容?

回答by Martin

What you're looking for is -f:

你要找的是-f

sendmail -F "Your name" -f "[email protected]" < your-message.txt

From the sendmail man page:

sendmail 手册页

 -Ffullname  Set the full name of the sender.

 -fname      Sets the name of the ``from'' person (i.e., the sender of the
             mail).  -f can only be used by ``trusted'' users (normally
             root, daemon, and network) or if the person you are trying to
             become is the same as the person you are.