【问题标题】:Failed to connect to server: Connection timed out (110)SMTP Connect() failed. Message was not sent.Mailer error: SMTP Connect() failed无法连接到服务器:连接超时 (110)SMTP Connect() 失败。邮件未发送。邮件程序错误:SMTP Connect() 失败
【发布时间】:2013-10-29 04:25:38
【问题描述】:

这是我的代码,但它仍然没有发送邮件。可能是什么问题?

require 'class.phpmailer.php';// path to the PHPMailer class
require 'class.smtp.php';

            $mail = new PHPMailer();  

            $mail->IsSMTP();  // telling the class to use SMTP
            $mail->Mailer = "smtp";
            $mail->Host="smtp.gmail.com";
            $mail->SMTPSecure='tls';
            $mail->Port =465;             
            $mail->SMTPAuth = true; // turn on SMTP authentication
            $mail->Username = "mymailgmail.com"; // SMTP username
            $mail->Password = "mypassword"; // SMTP password 
            $mail->SMTPDebug = 1;

            $mail->AddAddress("mymail@gmail.com","Title");
            $mail->SetFrom($visitor_email, $name);
            $mail->AddReplyTo($visitor_email,$name);

            $mail->Subject  = "Message from  Contact form";
            $mail->Body     = $user_message;
            $mail->WordWrap = 50;  

            if(!$mail->Send()) {
            echo 'Message was not sent.';
            echo 'Mailer error: ' . $mail->ErrorInfo;
            } else {
            echo 'Message has been sent.';
            }

// header('位置:thank-you.html'); }

【问题讨论】:

  • 在此处查看已接受的答案,它可能会有所帮助stackoverflow.com/questions/16048347/…
  • 还是什么都没有。托管我的文件的位置有问题吗?
  • 我会开始寻找方向,找出为什么错误消息说它正在尝试连接到端口 110,而您尝试将 PHPMailer 配置为使用端口 465。
  • this answer 帮助了我。我使用了 587 端口,而 465 对我不起作用。

标签: phpmailer php


【解决方案1】:

我曾经有过类似的问题。事实证明,尝试使用 ipv6 地址进行连接。从网络接口中删除 IPv6 地址后它工作正常。

【讨论】:

  • 谢谢你,你救了我的命!!! :D,但是你知道ipv6带来问题的原因吗?
  • @sergio-guillen-mantilla 在我的情况下,网络中的路由器/网关不支持 IPv6。数据包在网关中被丢弃。
猜你喜欢
  • 2013-09-01
  • 1970-01-01
  • 1970-01-01
  • 2014-02-17
  • 1970-01-01
  • 2016-08-12
  • 2018-06-16
  • 2015-07-02
  • 2018-01-18
相关资源
最近更新 更多