如何在从 nlog 发送的电子邮件的发件人地址中包含专有名称
How to include a proper name in the from address of emails sent from nlog
我希望 nlog 发送的电子邮件包含程序名称和发件人地址。我见过的所有示例都只是在 from 属性中包含电子邮件地址。如何为该字段添加专有名称?
<target xsi:type="Mail"
name="mailserver1"
subject="Layout"
to="someguy@fake.com"
from="john.doe@example.com"
smtpServer="mx1.example.com"
smtpPort="Integer"
layout="Layout" />
我到处搜索,终于自己弄明白了怎么做。我后来在 the documentation 中找到了与我的方法一致的说明。我希望这可以节省一些时间。名字应该放在第一位,然后电子邮件地址应该用尖括号 (<>
) 括起来。 XML 配置中不允许使用尖括号,因此您必须转义它们。
<target xsi:type="Mail"
name="mailserver1"
subject="Layout"
to="someguy@fake.com"
from="John Doe <john.doe@example.com>"
smtpServer="mx1.example.com"
smtpPort="Integer"
layout="Layout" />
我希望 nlog 发送的电子邮件包含程序名称和发件人地址。我见过的所有示例都只是在 from 属性中包含电子邮件地址。如何为该字段添加专有名称?
<target xsi:type="Mail"
name="mailserver1"
subject="Layout"
to="someguy@fake.com"
from="john.doe@example.com"
smtpServer="mx1.example.com"
smtpPort="Integer"
layout="Layout" />
我到处搜索,终于自己弄明白了怎么做。我后来在 the documentation 中找到了与我的方法一致的说明。我希望这可以节省一些时间。名字应该放在第一位,然后电子邮件地址应该用尖括号 (<>
) 括起来。 XML 配置中不允许使用尖括号,因此您必须转义它们。
<target xsi:type="Mail"
name="mailserver1"
subject="Layout"
to="someguy@fake.com"
from="John Doe <john.doe@example.com>"
smtpServer="mx1.example.com"
smtpPort="Integer"
layout="Layout" />