【发布时间】:2013-08-29 16:30:33
【问题描述】:
我们之前在 StackOverflow 上看到过一些关于 System.Web.Helpers.Webmail.Send 的类似问题,但我没有看到对发生的事情的正确解释。
关于to: 参数,the documentation 表示:
收件人的电子邮件地址。使用分号 (;) 分隔多个收件人。
我看到回答说"use a comma because the docs are wrong",或“使用分号”,或"maybe it's an environment issue"。
代码
WebMail.Send(
to: "joe.bloggs@mail.com,jane.bloggs@mail.com",
from: "no-reply@company.com",
subject: "Some Automated Email",
body: "<strong>Lorem Ipsum</strong>",
isBodyHtml: true
);
我尝试了几种情况:
joe.bloggs@mail.com;jane.bloggs@mail.com
未收到电子邮件:An invalid character was found in the mail header: ';'.
joe.bloggs@mail.com; jane.bloggs@mail.com
只有第一个收件人会收到电子邮件
joe.bloggs@mail.com,jane.bloggs@mail.com
都收到了邮件
joe.bloggs@mail.com, jane.bloggs@mail.com
都收到了邮件
joe.bloggs@mail.com, non-existant@mail.com
第一次收到邮件,但未发现异常:Mailbox unavailable. The server response was: 5.7.1 Unable to relay
non-existant@mail.com, joe.bloggs@mail.com
未收到电子邮件:An invalid character was found in the mail header: ','.
任何人都可以对此有所了解吗?实际上,我在不同的服务器上遇到了更多奇怪的行为;我使用 Exchange 进行上述测试,但实际上在 hMailServer 上遇到了不同的行为,其中joe.bloggs@mail.com,jane.bloggs@mail.com 导致静默失败,没有服务器错误,并且 hMailServer 日志中没有外发邮件。在带有 hMailServer 的系统上,我只成功使用了一个地址。
【问题讨论】: