doumeng3345 2016-09-01 20:51
浏览 726

Outlook没有收到来自php脚本的电子邮件

Okay, I'm at my whit's end here. I have a client whose site is hosted on GoDaddy and that uses Outlook. I've written a PHP script to send mail to one of their domain e-mail addresses from a contact form on their website.

I can get this e-mail to send to every single service except outlook/exchange/live/microsoft accounts.

I read that using PHPMailer was a good idea, so this is what I'm currently using to send mail:

//$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPDebug  = 2;                      
$mail->SMTPAuth   = true;                   
$mail->SMTPSecure = "ssl";                  
$mail->Host       = "a2plcpnl0287.prod.iad2.secureserver.net";       
$mail->Port       = 465;                    
$mail->Username   = "test@alamohomefinance.com";    
$mail->Password   = "xxxxxxx";          
$mail->SetFrom('yourname@yourdomain.com', 'First Last');
$mail->AddReplyTo("name@yourdomain.com","First Last");
$mail->Subject    = "PHPMailer Test Subject via smtp (hotmail), basic";
$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; 
$mail->MsgHTML($body);

$address = "jakerevans2@live.com"; 

if(!$mail->Send()) {
    error_log("Error from calculator!". $mail->ErrorInfo); 
} else {
 error_log("Success from calculator!");
}

This e-mail gets sent to my gmail account and some others, but not to my .live account or my client's Outlook address.

I've tried everything I've found on the internet so far, nothing is working. Any ideas or thoughts anyone?

Thanks!

EDIT: The Godaddy server has an SPF record that reads: v=spf1 include:spf.protection.outlook.com -all

I've created a DKIM key from https://www.port25.com/dkim-wizard/ and added a DKIM TXT record to GoDaddy, with the following details:

Host: key1._domainkey.alamohomefinance.com TXT Value: k=rsa\; p=MIIBIjA...

I've added a DKIM record, with the following details: Name: _dmarc.alamohomefinance.com TXT Value: v=DMARC1; p=quarantine; sp=none; ruf=mailto:user@example.com; rf=afrf; pct=100; ri=86400

Am testing now to see if these changes make a difference...

  • 写回答

2条回答 默认 最新

  • douzhi2012 2016-09-01 21:21
    关注

    First up, you should look at the PHPMailer troubleshooting guide, which has a little section on GoDaddy, and many other problems.

    You will get much better feedback on what's going on if you enable debug output of server messages, so set SMTPDebug = 2, and see what it says.

    GoDaddy is known to block outbound SMTP, and generally will either simply fail to connect (see many questions on SO about that), or cause TLS verification failures as you get redirected transparently to their mail servers.

    In your code you've got the smtp.live.com Host, but this username:

    $mail->Username   = "a2plcpnl0287.prod.iad2.secureserver.net"
    

    secureserver.net is the domain used for GoDaddy's mail servers, and that user name is the name of an actual GoDaddy mail server, so it seems very unlikely that you should be using it as a user id for live.com, especially since GoDaddy will be rotating mail servers frequently, so you're unlikely to get the same one every time - is that really your login ID for live.com?

    I'm also suspicious of the phrasing of your question: you do not need to connect to live.com to send email to live.com - there's nothing stopping you sending to a live.com address from a connection through gmail, so it sounds like you may have a conceptual issue. The Host, Username and Password properties are for the mail server that you send out through, not that you are sending mail to.

    As I said, normally GoDaddy doesn't allow remote SMTP at all, so I'm very surprised if you've had it working without using a GoDaddy mail server, so I suspect you've had something else work, not what you think.

    I can also see you've based your code on an obsolete example, so make sure you're running the latest PHPMailer.

    Update:

    I noticed something critical. The code does not call $mail->isSMTP();. This means that it's not using SMTP at all, it's using the default mail() function, and as such none of the SMTP config makes any difference at all. The message will be submitted to your local mail server, which will then relay through GoDaddy's server. Look in your mail server's log file to see what's happening, usually in /var/log/mail.log or similar.

    评论

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)