doukuizuo1795 2014-12-03 13:16
浏览 65
已采纳

PHPMailer,SMTP错误无法连接到smtp主机

I have a simple member management on my site. It is based on the php session. Where users can login, change password, request for a new password, logout. All of these functions works well when I perform in my PC. Request for a new password works fine and mail sent successfully, new password is received in mail.

If I try to request for a new password in mobile(iPhone) (Opened the website through local ip) I get the following error SMTP Error Could not connect to smtp host Mail not sent, try again!. But, when i do the same in my PC mail was sent successfully. When I try in samsung mobile (S4), it works sometime and sometimes error.

mymail function receives the to address, subject, message and from address from a call in other php file. Message contains the username and new password, and it is html code.

I'll explain you clearly with the code..

This is the send_mail.php. "mymail" function is called from another php file.

<?php
//include phpmailer
require_once ('class.phpmailer.php');
function mymail($mto, $msub, $mbody, $mfrom) {
$mail = new PHPMailer();
$mail -> IsSMTP();
$mail -> SMTPAuth = true;
$mail -> SMTPSecure = "tls";

$mail -> Host = "email-smtp.us-west-2.amazonaws.com";
$mail -> Username = "Provided by Amazon SES";
$mail -> Password = "Provided by Amazon SES";

$mail -> SetFrom("$mfrom", '');
//from (verified email address)
$mail -> Subject = "$msub";
$body = "$mbody";
$body = eregi_replace("[\]", '', $body);
$mail -> MsgHTML($body);
$mail -> AddAddress("$mto", "");

if ($mail -> Send()) {
    return 1;
} else {
    echo "<br> Mail not sent, try again!";
    return 0;
}
}
?>

And, yes I am sending mail from and to the verified email in Amazon SES. I have tryed to edit the php code. Removed the sha1 function from other php file and no use. I think the problem is in this function.Generally php is server side, but, will the php processor works differently when accessed from mobile or pc? I've been trying from yesterday night. Done enough research in google. Thanks in advance.

  • 写回答

4条回答 默认 最新

  • dtr53557 2014-12-03 18:43
    关注

    Try updating the PHPMailer. That should fix the issue

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog