本文介绍了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 = "[email protected]"; // SMTP username
$mail->Password = "mypasswword"; // SMTP password
$Mail->Priority = 1;
$mail->AddAddress("[email protected]","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.';
}
推荐答案
删除或注释掉该行 -
Remove or comment out the line-
$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()失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!