Windows 在SendGrid.Net上使用SmartHost的IIS SMTP

Windows 在SendGrid.Net上使用SmartHost的IIS SMTP,windows,iis,server,sendgrid,smarthost,Windows,Iis,Server,Sendgrid,Smarthost,我将我的Windows Server 2016配置为使用IIS从php接收邮件(),并将其发送到stmp.sendgrid.net 为了测试我的配置,我可以telnet我的本地主机,并从那里发送电子邮件,没有问题 但是,如果我通过mail()php函数发送电子邮件,SendGrid会接收请求,但会因以下错误而阻止请求: REASON550 5.7.1 [167.89.55.39 11] Our system has detected that this message is not RFC 53

我将我的Windows Server 2016配置为使用IIS从php接收邮件(),并将其发送到stmp.sendgrid.net

为了测试我的配置,我可以telnet我的本地主机,并从那里发送电子邮件,没有问题

但是,如果我通过mail()php函数发送电子邮件,SendGrid会接收请求,但会因以下错误而阻止请求:

REASON550 5.7.1 [167.89.55.39 11] Our system has detected that this message is not RFC 5322 compliant: Multiple 'From' headers found. To reduce the amount of spam sent to Gmail, this message has been blocked. Please visit https://support.google.com/mail/?p=RfcMessageNonCompliant and review RFC 5322 specifications for more information. h190si13823586ite.62 - gsmtp 
所以这个错误是因为IIS将电子邮件发送到sendgrid,因此,它被标记为垃圾邮件


什么原因会导致这种情况?

显然,在使用PHP mail()时需要一个详细的标题,而不是在使用telnet时

对于mininum上的PHP mail():

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
$headers .= "From: your@email.com" . "\r\n";

看来IIS不仅仅是作为一个中继,而是附加了一些头文件。是否可以在MIME消息转到IIS之前和之后查看它?然后您可以将问题隔离到代码或服务器。