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 cgictest.cgi文件无法访问
  • ¥20 删除和修改功能无法调用
  • ¥15 kafka topic 所有分副本数修改
  • ¥15 小程序中fit格式等运动数据文件怎样实现可视化?(包含心率信息))
  • ¥15 如何利用mmdetection3d中的get_flops.py文件计算fcos3d方法的flops?
  • ¥40 串口调试助手打开串口后,keil5的代码就停止了
  • ¥15 电脑最近经常蓝屏,求大家看看哪的问题
  • ¥60 高价有偿求java辅导。工程量较大,价格你定,联系确定辅导后将采纳你的答案。希望能给出完整详细代码,并能解释回答我关于代码的疑问疑问,代码要求如下,联系我会发文档
  • ¥50 C++五子棋AI程序编写
  • ¥30 求安卓设备利用一个typeC接口,同时实现向pc一边投屏一边上传数据的解决方案。