douying6206 2015-01-27 20:13
浏览 25
已采纳

PHP脚本拒绝发送到Outlook.com

This seems like a reoccurring problem with outlook.com for many individuals.

My script below works with @college.edu, @gmail.com , but on outlook.com - it refuses to reach even the junk folder, nevermind the inbox - how can I modify it to fix it?

I have checked my sender domain to ensure it is not blacklisted.

Script:

<?php
$doraccount = 'noreply@mydomain.com';

$pathwayurl = $_POST['pathway_url'];

$to = $_POST['email_address'];
$subject = "Path Share";
#message for email
$message = '<html><body><div style=width:362px;display:block;margin:0% auto;>';
$message .= "<img src='http://domain.com/sites/default/files/togo3.gif' alt='my site' /></div>";
#$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
#$message .= "<tr style='background: #eee;'></tr>";
$message .= '<div><p>Thank you for using Pathway tool. We have provided you with a link to the below.  Please check out our other programs and offerings on the <a href="http://www.oursite.com">our site website</a></p>';
$message .= "<br /><br /><strong>link:</strong> <tr><td>" . $pathwayurl ."</div>";
$message .= '<div><p>The Team<br /><a href="mailto:info@domain.com">info@domain.com</a></p></div>';;
$message .= "</body></html>";

$headers  = "MIME-Version: 1.0" . PHP_EOL;
$headers .= "Content-Type: text/html; charset=ISO-8859-1" . PHP_EOL;
$headers .= "From: " . $doraccount . PHP_EOL;

if(mail($to,$subject,$message,$headers)){
    echo "<div style=text-align:center;>
            <img src='http://domain.com/sites/default/files/togo3.gif' alt='domain' /> <br />
            <strong>The email was successfully sent.</strong>
            <br> Redirecting you back to the pathway. 
         </div>";
    header('Refresh: 3;url='.$pathwayurl);
    #echo $message;


} else {
    echo "The email was NOT sent.";
}
?>

Logs showing: Unfortunately, messages from xx.xx.xx.xx weren't sent. Please contact your Internet service provider since part of their network is on our block list.

  • 写回答

1条回答 默认 最新

  • douying0108 2015-01-27 20:17
    关注

    You redefine your header a few times. You want the following:

    $headers  = "MIME-Version: 1.0" . PHP_EOL;
    $headers .= "Content-Type: text/html; charset=ISO-8859-1" . PHP_EOL;
    $headers = "From: " . $doraccount . "
    " . PHP_EOL;
    
    $headers  = "MIME-Version: 1.0" . PHP_EOL;
    $headers .= "Content-Type: text/html; charset=ISO-8859-1" . PHP_EOL;
    $headers .= "From: domain<$from>" . PHP_EOL;
    

    First you set the $header to MIME-Version: 1.0" . PHP_EOL, then add "Content-Type: text/html; charset=ISO-8859-1" . PHP_EOL. Then you overwrite all previous data with "MIME-Version: 1.0" . PHP_EOL; $headers .= "Content-Type: text/html; charset=ISO-8859-1" . PHP_EOL; $headers .= "From: domain<$from>" . PHP_EOL;. The next line you clear the $header, and set it to "MIME-Version: 1.0" . PHP_EOL, followed by "Content-Type: text/html; charset=ISO-8859-1" . PHP_EOL and "From: domain<$from>" . PHP_EOL. In the end, your header is as following:

    MIME-Version: 1.0
    
    Content-Type: text/html; charset=ISO-8859-1
    
    From: domain<$from>
    
    

    You overwrite your old From header, so this might make Outlook think it's a spam mail and blacklist it immediatly (so it doesn't even reach the spam folder)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 PointNet++的onnx模型只能使用一次
  • ¥20 西南科技大学数字信号处理
  • ¥15 有两个非常“自以为是”烦人的问题急期待大家解决!
  • ¥30 STM32 INMP441无法读取数据
  • ¥15 R语言绘制密度图,一个密度曲线内fill不同颜色如何实现
  • ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包
  • ¥15 用visualstudio2022创建vue项目后无法启动
  • ¥15 x趋于0时tanx-sinx极限可以拆开算吗
  • ¥500 把面具戴到人脸上,请大家贡献智慧,别用大模型回答,大模型的答案没啥用
  • ¥15 任意一个散点图自己下载其js脚本文件并做成独立的案例页面,不要作在线的,要离线状态。