![](/img/trans.png)
[英]PHPMailer error Connection: opening to ssl://smtp.gmail.com:465, timeout=300, options=array ()
[英]PHPMailer error sending mail with smtp.gmail.com
經過phpmailer的所有步驟並查看stackoverflow之后。 測試了所有我遇到的問題都可以找到的答案,但這對我不起作用。
My code is simple:
<?php
require 'PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->SMTPDebug = 1; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'I entered a valid gmail'; // SMTP username
$mail->Password = 'I entered my password(I'm not giving it to you people, I know what you can do ;) )'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->SMTPKeepAlive = true;
$mail->Mailer = "smtp";
$mail->From = 'The email its sent from';
$mail->FromName = 'Lobby desk';
$mail->addAddress(' Recipients mail '); // Name is optional
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
?>
我希望有人可以指出我的代碼出了什么問題以及為什么會產生錯誤:
SMTP connect()失敗
和:
SMTP錯誤:密碼命令失敗:534-5.7.14請通過Web瀏覽器和534-5.7.14登錄,然后重試
我為gmail帳戶輸入了正確的密碼,並修改了設置以允許安全性較低的應用程序。
與往常一樣,非常感謝那些認真對待我的用戶。
請在您的gmail帳戶設置中檢查一次,以獲取使用此帳戶作為郵件發送者的權限。 我認為這可能是問題所在。
這行的問題
$mail->Password = 'I entered my password(I'm not giving it to you people, I know what you can do ;) )';
^ ^^^ ^
改成
$mail->Password = "I entered my password(I'm not giving it to you people, I know what you can do ;) )";
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.