SMTP connect()失败

时间:2015-04-01 10:28:46

标签: php email smtp-auth

我的php代码上的SMTP connect()失败错误。

我已经在堆栈溢出中引用了所有解决方案,但我的代码

没有任何效果

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

没有消息发送到收件人地址。

我已取消注释以下行

extension=php_openssl.dll

php文件中存在php_openssl.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"

1 个答案:

答案 0 :(得分:0)

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

$mail->SMTPDebug = 3;