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 输出区间内所有的完数的个数。 要简单点的程序
  • ¥15 asp.core 权限控制怎么做,需要控制到每个方法
  • ¥20 while循环中OLED显示中断中的数据不正确
  • ¥15 这个视频里的stm32f4代码是怎么写的
  • ¥15 串口发送数据和接收数据
  • ¥15 JNA调用DLL报堆栈溢出错误(0xC00000FD)
  • ¥15 请教SGeMs软件的使用
  • ¥15 自己用vb.net编写了一个dll文件,如何只给授权的用户使用这个dll文件进行打包编译,未授权用户不能进行打包编译操作?
  • ¥50 深度学习运行代码直接中断
  • ¥20 需要完整的共散射点成像代码