1
我的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"
請任何身體幫助我,解決我的問題。對我來說這很重要 – 2015-04-01 12:13:52