1

我正在使用 PHP 的mail()函数向管理员发送“忘记密码”链接和报告。当我使用 Gmail 对其进行测试时,一切正常。但是,当我将电子邮件发送到 Microsoft 365 邮箱时,即使在垃圾文件夹中,邮件也不会出现。

我应该怎么办?

UPD

我尝试使用标题和“返回路径”附加参数。我的代码如下所示:

        $to      = 'my_email@corporate_domain.com';
        $subject = 'test';
        $message = 'test';
        $headers  = 'MIME-Version: 1.0' . "\r\n";
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
        $headers .= "To: Tamara <my_email@corporate_domain.com>" . "\r\n";
        $headers .= 'From: Sender <sender@domain.com>' . "\r\n";
        $headers .= 'Reply-To: Sender <sender@domain.com>'. "\r\n";
        $headers .=  "Return-Path:<Sender@domain.com>"."\r\n";

        mail($to, $subject, $message, $headers, "-r sender@domain.com");

我终于收到了退回邮件,上面写着:

暂停服务; 客户端主机 [5.166.*.68] 被阻止使用阻止列表 1,来自 IP 的邮件被禁止;要请求从此列表中删除,请将此邮件转发至 delist@messaging.microsoft.com 并附上您的 IP 地址。

但是没有邮件发送到这封电子邮件,甚至发送到这个域。我的 IP 怎么可能已经被封禁了?

4

2 回答 2

0

尝试使用以下方法发送测试电子邮件:

$to      = 'myemail@company-domain.com';
$subject = 'test';
$message = 'test';
$headers = 'From: yourValidEmail@example.com' . "\r\n" .
           'Reply-To: yourValidEmail@example.com' . "\r\n" .
           'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

如果这可行并且您现在在垃圾邮件/垃圾邮件文件夹中看到您的电子邮件,我建议您查看设置PTR 记录并确保您的域名具有正确的反向 dns 设置以指向您的服务器 IP 地址。请参阅反向 DNS

于 2012-12-26T19:26:03.800 回答
0

我的第一个建议是首先删除 headers 参数中的任何自定义内容,并查看是否只有普通电子邮件首先通过。如果它失败并且您正在发送纯文本电子邮件,我建议检查邮件服务器发送地址上的 PTR 记录。您应该能够在您在 gmail 中收到的电子邮件的标题中看到这一点。

于 2012-12-26T19:03:57.417 回答