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 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 wpf界面一直接收PLC给过来的信号,导致UI界面操作起来会卡顿
  • ¥15 init i2c:2 freq:100000[MAIXPY]: find ov2640[MAIXPY]: find ov sensor是main文件哪里有问题吗
  • ¥15 运动想象脑电信号数据集.vhdr
  • ¥15 三因素重复测量数据R语句编写,不存在交互作用
  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab