我想使用的PHPMailer, 我已經啓用opensll和它加載 我使用XAMPP和PHPStorm不能理解PHPMailer的調試日誌
SERVER -> CLIENT: 220 smtp.gmail.com ESMTP z88sm9679wrb.26 - gsmtp
CLIENT -> SERVER: EHLO PhpStorm 2016.1.2
SERVER -> CLIENT: 501-5.5.4 HELO/EHLO argument "PhpStorm 2016.1.2" invalid, closing connection.501 5.5.4 https://support.google.com/mail/?p=helo z88sm9679wrb.26 - gsmtp
SMTP ERROR: EHLO command failed: 501-5.5.4 HELO/EHLO argument "PhpStorm 2016.1.2" invalid, closing connection.501 5.5.4 https://support.google.com/mail/?p=helo z88sm9679wrb.26 - gsmtp
CLIENT -> SERVER: HELO PhpStorm 2016.1.2
SERVER -> CLIENT:
SMTP ERROR: HELO command failed:
SMTP NOTICE: EOF caught while checking if connected
SMTP Error: Could not connect to SMTP host.
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
這裏是我的代碼
<?php
/**
* This example shows settings to use when sending via Google's Gmail servers.
*/
//SMTP needs accurate times, and the PHP time zone MUST be set
//This should be done in your php.ini, but this is how to do it if you don't have access to that
date_default_timezone_set('Etc/UTC');
require '../PHPMailerAutoload.php';
//Create a new PHPMailer instance
$mail = new PHPMailer;
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 2;
//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';
//Set the hostname of the mail server
$mail->Host = 'smtp.gmail.com';
//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
$mail->Port = 587; //ssl : 465 --- tls:587;
//Set the encryption system to use - ssl (deprecated) or tls
$mail->SMTPSecure = 'tls';
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication - use full email address for gmail
$mail->Username = "[email protected]";
//Password to use for SMTP authentication
$mail->Password = "*****";
//Set who the message is to be sent from
$mail->setFrom('[email protected]', 'Abou May');
//Set an alternative reply-to address
//$mail->addReplyTo('[email protected]', 'First Last');
//Set who the message is to be sent to
$mail->addAddress('[email protected]', 'Abou May');
//Set the subject line
$mail->Subject = 'PHPMailer GMail SMTP test';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';
//Attach an image file
$mail->addAttachment('images/phpmailer_mini.png');
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
I have read lots of documentation, bu I cannot figure out the reason of this error.
可有人givz我的例子代碼?
出了什麼問題?
我讀了所有的故障排除
節「SMTP錯誤:無法連接到SMTP主機」
這也可能顯示爲SMTP連接()失敗或調用郵件(),而不連接在調試輸出。這通常被稱爲PHPMailer問題,但幾乎總是由本地DNS故障,防火牆阻塞(例如GoDaddy所做的)或本地網絡上的其他問題導致。這意味着PHPMailer無法聯繫您在Host屬性中指定的SMTP服務器,但並未明確說明原因。它也可能是由於沒有加載openssl擴展引起的(請參閱下面的加密註釋)。
Smtp在您的Google帳戶中啓用? – DarkSideKillaz
我不知道這是否是原因,但在我的情況下,我不得不登錄我的gmail帳戶並在那裏更改設置,例如「允許遠程應用程序的安全性較低的登錄信息..」。我不記得他們稱之爲什麼該設置 –