【问题标题】:SMTP connect() failedSMTP 连接()失败
【发布时间】:2015-06-05 23:03:31
【问题描述】:

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

我已经参考了堆栈溢出中的所有解决方案,但我的代码没有任何效果

我正在使用 php、mysql 和服务器版本 5.1.30

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

我已经取消了下面一行的注释

extension=php_openssl.dll

ext文件夹中存在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"

【问题讨论】:

  • 请任何人帮助我,解决我的问题。这对我来说非常重要

标签: php email smtp-auth


【解决方案1】:

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

$mail->SMTPDebug = 3; 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-06-13
    • 2015-08-09
    • 1970-01-01
    • 2016-11-10
    • 2014-05-20
    • 2018-09-03
    • 2016-06-12
    • 1970-01-01
    相关资源
    最近更新 更多