SMTP连接()失败.我的php代码中出现


SMTP connect() failed

SMTP connect()失败错误。

我已经参考了堆栈溢出中的所有解决方案,但没有什么能对我的代码起作用

我使用的是php、mysql和服务器版本5.1.30

没有邮件发送到收件人地址。

我已经取消注释下面的行

extension=php_openssl.dll

ext文件夹中存在php_opensl.dll文件。

email.php
<?php 
include "PHPMailer-master/class.phpmailer.php";
include "PHPMailer-master/class.smtp.php";
$mail = new PHPMailer(); 
$mail->IsSMTP(); // send via SMTP
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Host = "smtp.gmail.com";
$mail->port = 465;
echo !extension_loaded('openssl')?"Not Available":"Available";
$mail->Username = "jansiantony92@gmail.com"; // SMTP username
$mail->Password = "xxxxxxxxx"; // SMTP password
$webmaster_email = "asha.it33@gmail.com"; //Reply to this email ID
$email="aasha.vkm@domain.com"; // Recipients email ID
$name="name"; // Recipient's name
$mail->From = $webmaster_email;
$mail->FromName = "Webmaster";
$mail->AddAddress($email,$name);
$mail->AddReplyTo($webmaster_email,"Webmaster");
$mail->WordWrap = 50; // set word wrap
//$mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment
//$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // attachment
$mail->IsHTML(true); // send as HTML
$mail->Subject = "This is the subject";
$mail->Body = "Hi,
This is the HTML BODY "; //HTML Body
$mail->AltBody = "This is the body when user views in plain text format"; //Text Body
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent";
}
?>

始终显示未加载的ssl。有什么解决方案可以解决这个错误

my php.ini file
[mail function]
; For Win32 only.
SMTP = smtp.gmail.com
smtp_port = 25
; For Win32 only.
sendmail_from = jansiantony92@gmail.com
; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path ="'"C:'xampp'sendmail'sendmail.exe'" -t -i"

您需要打开调试;您将能够看到错误消息的详细信息;

$mail->SMTPDebug = 3;