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 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器