如何代表发送电子邮件?

时间:2016-01-11 02:06:35

标签: php email spf

我们运营一个机密广告网站。

联系表单(php)通过电子邮件将消息直接发送给广告的作者。我们正在考虑遵循这个Best practice for web-generated emailers

To: recipient@domain1.com
From: writer-of-the-message@domain2.com
Sender: noreply@classified-website.com
Reply-To: writer-of-the-message@domain2.com

可交付性并不完美(有些人,比如雅虎,对他们的DMARC政策非常积极)。如果消息作者(FROM:)是@yahoo且收件人(TO:)是@gmail,则为例:

<xxxxxx@gmail.com>: host gmail-smtp-in.l.google.com[xx.xxx.xxx.xx] said:
550-5.7.1 Unauthenticated email from yahoo.com is not accepted due to domain's
550-5.7.1 DMARC policy. Please contact administrator of yahoo.com domain if
550-5.7.1 this was a legitimate mail. Please visit
550-5.7.1 https://support.google.com/mail/answer/2451690 to learn about DMARC
550-5.7.1 initiative. jq5si20832837wjc.74 - gsmtp (in reply to end of DATA command)

例如,如果消息作者(FROM:)是@yahoo而收件人(TO:)是@hotmail:

Diagnostic-Code: smtp; 550 5.7.0 (COL004-MC4F54) Unfortunately, messages
from (xx.xx.xx.xx) on behalf of (yahoo.com) could not be delivered due to
domain owner policy restrictions.

解决方案是什么?

要求:在他们的电子邮件客户端中,收件人应该能够在需要时将writer-of-the-message@domain2.com标记为垃圾邮件,而不是noreply@classified-website.com

我们已经看到一些网站使用这个有争议的解决方案:

To: recipient@domain1.com
From: "writer-of-the-message@domain2.com" <noreply@classified-website.com>
Reply-To: writer-of-the-message@domain2.com

更新:根据要求简化了PHP代码:

mail(
    $to,
    'Email title',
    'Email body',
    "From: \"" . $from . "\" <" . $from . ">\n" .
    "Sender: noreply@classified-website.com\n" .
    "Reply-To: \"" . $from  . "\" <" . $from . ">\n" .
    "Return-Path: " . $from,
    '-f noreply@classified-website.com'
);

0 个答案:

没有答案