SMTP Connect() 失败.邮件未发送.邮件程序错误:SMTP Connect() 失败 [英] SMTP Connect() failed. Message was not sent.Mailer error: SMTP Connect() failed

查看:37
本文介绍了SMTP Connect() 失败.邮件未发送.邮件程序错误:SMTP Connect() 失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将邮件发送到 gmail 地址,但它不断收到此错误SMTP -> 错误:无法连接到服务器:连接超时 (110)SMTP 连接()失败.消息未发送.邮件程序错误: SMTP Connect() 失败."可能是什么问题?

Am trying to send mail to a gmail address but it keeps on getting this error "SMTP -> ERROR: Failed to connect to server: Connection timed out (110)SMTP Connect() failed. Message was not sent.Mailer error: SMTP Connect() failed." What could be the problem?

        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->SMTPDebug = 2;
            $mail->Mailer = "smtp";
            $mail->Host = "ssl://smtp.gmail.com";
            $mail->Port = 587;
            $mail->SMTPAuth = true; // turn on SMTP authentication
            $mail->Username = "myemail@gmail.com"; // SMTP username
            $mail->Password = "mypasswword"; // SMTP password 
            $Mail->Priority = 1;

            $mail->AddAddress("myemail@gmail.com","Name");
            $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.';
            }

推荐答案

删除或注释掉该行-

$mail->IsSMTP();

它对你有用.

我已经检查并试验了来自不同网站的许多答案,但除了上述解决方案之外没有任何解决方案.

I have checked and experimented many answers from different sites but haven't got any solution except the above solution.

这篇关于SMTP Connect() 失败.邮件未发送.邮件程序错误:SMTP Connect() 失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆