PHPMailer Smtp连接失败。连接超时(110)
我尝试了端口PHPMailer Smtp连接失败。连接超时(110),php,smtp,phpmailer,Php,Smtp,Phpmailer,我尝试了端口465和587。无法访问php.ini文件,还尝试设置超时限制。不行openssl已启用 核对: 我总是会遇到同样的错误: SMTP错误:无法连接到服务器:连接超时(110) SMTP连接()失败。 邮件程序错误:SMTP连接()失败 如果错误消息中没有指向的链接,则表示您正在运行旧版本,您仍应阅读指南;超时意味着网络问题,可能是出站防火墙阻塞。我应该提到,当我在本地主机上尝试它时,它可能会工作。但不是在托管网站上。确切地说,你说的是两个不同的网络,其中一个有问题。遇到同样的问题
465
和587
。无法访问php.ini
文件,还尝试设置超时限制。不行<代码>openssl已启用
核对:
我总是会遇到同样的错误:
SMTP错误:无法连接到服务器:连接超时(110)
SMTP连接()失败。
邮件程序错误:SMTP连接()失败
如果错误消息中没有指向的链接,则表示您正在运行旧版本,您仍应阅读指南;超时意味着网络问题,可能是出站防火墙阻塞。我应该提到,当我在本地主机上尝试它时,它可能会工作。但不是在托管网站上。确切地说,你说的是两个不同的网络,其中一个有问题。遇到同样的问题,但仍然找不到答案如果错误消息中没有指向的链接,你运行的是旧版本,无论如何你都应该阅读指南;超时意味着网络问题,可能是出站防火墙阻塞。我应该提到,当我在本地主机上尝试它时,它可能会工作。但不是在托管网站上。没错,你说的是两个不同的网络,其中一个有问题。遇到同样的问题,但仍然找不到答案
date_default_timezone_set('Etc/UTC');
require 'phpmailer/PHPMailerAutoload.php'; //Create a new PHPMailer instance
$mail = new PHPMailer;
//Tell PHPMailer to use SMTP
$mail->IsSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 2;
//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';
//Set the hostname of the mail server
$mail->Host = 'smtp.gmail.com';
// use
// $mail->Host = gethostbyname('smtp.gmail.com');
// if your network does not support SMTP over IPv6
//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
$mail->Port = 587;
//Set the encryption system to use - ssl (deprecated) or tls
$mail->SMTPSecure = 'tls';
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication - use full email address for gmail
$mail->Username = "username@gmail.com";
//Password to use for SMTP authentication
$mail->Password = "mypassword";
//Set who the message is to be sent from
$mail->setFrom('username@gmail.com', 'User');
//Set an alternative reply-to address
//Set who the message is to be sent to
$mail->addAddress($email,$name);
//Set the subject line
$mail->Subject = 'Subject';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$body = "body";
$mail->msgHTML($body);
//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';
//Attach an image file
//$mail->addAttachment('images/phpmailer_mini.png');
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
<?php echo (extension_loaded('openssl')?'SSL loaded':'SSL not loaded')."\n"; ?>