SMTP连接()失败
问题描述:
我的PHP代码上的SMTP connect()失败错误。SMTP连接()失败
我已经提到的所有解决方案堆栈溢出,但没有将我的代码工作
我使用的PHP,MySQL和服务器版本5.1.30
无消息发送给收件人的地址。
我已经取消对以下行
extension=php_openssl.dll
php_openssl.dll文件中的ext文件夹存在。
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 = "[email protected]"; // SMTP username
$mail->Password = "xxxxxxxxx"; // SMTP password
$webmaster_email = "[email protected]"; //Reply to this email ID
$email="[email protected]"; // 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 = [email protected]
; 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;
请任何身体帮助我,解决我的问题。对我来说这很重要 – 2015-04-01 12:13:52