如何更改From:
使用的发件人姓名或电子邮件地址(mutt
标题)?
通常,mutt根据你在From:
中设置的the from
configuration variable设置~/.muttrc
头:
set from="Fubar <foo@bar>"
如果未设置,mutt
默认使用EMAIL
环境变量。在这种情况下,你可以在命令行上调用mutt这样的东西(而不是你在评论中如何显示):
EMAIL="foo@bar" mutt -s '$MailSubject' -c "abc@def"
但是,如果你想在编写时能够编辑From:
标题,你需要configure mutt
to allow you to edit headers first。这涉及在~/.muttrc
中添加以下行:
set edit_headers=yes
之后,下次打开mutt并编写电子邮件时,会弹出包含标题的所选文本编辑器,以便您编辑它们。这包括From:
标题。
如果您只想更改一次,可以在命令行中指定“from”标题,例如:
mutt -e 'my_hdr From:[email protected]'
my_hdr
是mutt提供自定义标头值的命令。
最后一句话,不要做坏事!
在发送电子邮件之前,您可以按<ESC> f
(Escape后跟f)更改From:
地址。
约束:这仅适用于在curses模式下使用mutt并且不想编写脚本或者想要永久更改地址的情况。然后其他解决方案更好!
一个特例就是如果你在〜/ .muttrc中使用了类似下面的结构:
# Reset From email to default
send-hook . "my_hdr From: Real Name <[email protected]>"
这个send-hook将覆盖以下任何一个:
mutt -e "set [email protected]"
mutt -e "my_hdr From: Other Name <[email protected]>"
您的电子邮件仍会显示标题:
From: Real Name <[email protected]>
在这种情况下,我发现的唯一命令行解决方案实际上是覆盖了send-hook本身:
mutt -e "send-hook . \"my_hdr From: Other Name <[email protected]>\""
对于一次性更改,您可以这样做:
出口EMAIL='[email protected]'; mutt -s“Elvis is dead”[email protected]
100%工作!
要使用Sender和Recipient邮件地址一起发送邮件正文中的HTML内容,您可以尝试以下方法,
export EMAIL="[email protected]" && mutt -e "my_hdr Content-Type: text/html" -s "Test Mail" "[email protected]" < body_html.html
文件:body_html.html
<HTML>
<HEAD> Test Mail </HEAD>
<BODY>
<p>This is a <strong><span style="color: #ff0000;">test mail!</span></strong></p>
</BODY>
</HTML>
注意:在RHEL,CentOS,Ubuntu中测试过。