dongyu2764 2015-08-04 20:06
浏览 44

SMTP错误 - 无法连接到网络

I've been trying to implement SMTP with PHPMailer for about a week now. I'm revising my old mail() php script and am having difficulty even setting up a live test taken right from the example since I keep receiving the same error. I'm currently running a HostGator dedicated server and my MX record (mail server) is through Office 365/Outlook. For some reason, I keep getting the can't connect to network error as seen in the image below.

enter image description here

My code is below which I took from the github SMTP example. I originally used port 587 with 'tls' authentication but this did not work and after speaking with Microsoft they suggested I do port 25 with no authentication. Still the same error. Can anyone explain to me what i'm doing wrong or suggest a better route of approach? Thanks!

Code:

 <?
 require(dirname(__FILE__)."/PHPMailerAutoload.php");
 $mail = new PHPMailer;
 $mail->isSMTP();
 $mail->SMTPDebug = 2;
 $mail->Debugoutput = 'html';
 $mail->Host = 'smtp.office365.com';
 $mail->Port = 25;
 $mail->SMTPSecure = 'tls';
 $mail->SMTPAuth = true;
 $mail->Username = "jason@***.com";
 $mail->Password = "***";
 $mail->setFrom('jason@***.com', 'Jason');
 $mail->addReplyTo('jason@***.com', 'Jason');
 $mail->addAddress('jason@***.com', 'Jason');
 $mail->Subject = 'PHPMailer GMail SMTP test';
 $mail->msgHTML($email_message);
 $mail->AltBody = 'This is a plain-text message body';
 if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
 } else {
echo "Message sent!";
 }
 ?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度