gpt4 book ai didi

PHPMailer 不适用于 gmail

转载 作者:太空宇宙 更新时间:2023-11-03 13:39:45 27 4
gpt4 key购买 nike

在尝试让我的 PHPMailer 与 gmail 一起运行几天后,我必须在这里找到一些帮助。我几乎阅读了在这里或在 Google 中可以找到的所有内容,但直到现在这些想法都没有帮助。我在用* Windows 7 家庭普通版* 带有 PHP 版本的 Wampserver 2.2。 PHP 版本 5.4.3 所有必要的扩展都像 e. G。 php_opensll* PHPMailer 5.2.9

这是我正在使用的脚本:

<?php
//require 'PHPMailerAutoload.php'; // <<== I have tried this also - no sucess

require 'class-phpmailer.php';
require "class-smtp.php"; //"PHPMailerAutoload.php";
// $mail->PluginDir //WB, 30 Nov 2014:omited if all files from phpmailer are in the same folder
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp.gmail.com";
$mail->Mailer = 'smtp';
$mail->SMTPAuth = true;
// I have tried both - TLS and SSL - with the required ports ==>> both are not working
$mail->Port = 465;
$mail->SMTPSecure = 'ssl';
// or try these settings (worked on XAMPP and WAMP):
//$mail->Port = 587;
//$mail->SMTPSecure = 'tls';

$mail->Username = "wie****@gmail.com"; //my password ==>> works if I make a login oline to my account
$mail->Password = "*************"; //my password ==>> works if I make a login oline to my account

$mail->SMTPDebug = 2; // <<== enables SMTP debug information (for testing)

$mail->IsHTML(true); // if you are going to send HTML formatted emails
$mail->SingleTo = true; // if you want to send a same email to multiple users. multiple emails will be sent one-by-one.

$mail->From = "wie****@gmail.com"; //my gmail mail account
$mail->FromName = "My Name";

$mail->addAddress("art******@yahoo.com","art******"); //my yahoo mail account
//$mail->addAddress("user.2@gmail.com","User 2");

//$mail->addCC("user.3@ymail.com","User 3");
//$mail->addBCC("user.4@in.com","User 4");

$mail->Subject = "Testing PHPMailer with localhost";
$mail->Body = "Hi,<br /><br />This system is working perfectly.";

if(!$mail->Send())
echo "Message was not sent <br />PHPMailer Error: " . $mail->ErrorInfo;
else
echo "Message has been sent";
?>

我已经在尝试我能在网上找到的任何变体,但没有任何效果。

我试过了- 'PHPMailerAutoload.php' 和 'class.phpmailer.php' 作为必需的类- “$mail->SMTPSecure = 'ssl';”和“$mail->Port = 465;” 以及与- “$mail->SMTPSecure = 'tls';”和“$mail->Port = 587;”

调试日志文件如下:

Debug-Log when using TLS with port 587

SMTP -> FROM SERVER:220 mx.google.com ESMTP cq6sm24503844pad.30 - gsmtp SMTP -> FROM SERVER: 250-mx.google.com at your service, [121.54.112.183] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8 SMTP -> FROM SERVER:220 2.0.0 Ready to start TLS SMTP -> FROM SERVER: 250-mx.google.com at your service, [121.54.112.183] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8 SMTP -> ERROR: Password not accepted from server: 534-5.7.14 Please log in via your web browser and 534-5.7.14 then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/bin/answer.py?answer=78754 cq6sm24503844pad.30 - gsmtp SMTP -> FROM SERVER:250 2.1.5 Flushed cq6sm24503844pad.30 - gsmtp SMTP -> FROM SERVER:530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 cq6sm24503844pad.30 - gsmtp SMTP -> ERROR: MAIL not accepted from server: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 cq6sm24503844pad.30 - gsmtp The following From address failed: wiedeia@gmail.com : MAIL not accepted from server,530,5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 cq6sm24503844pad.30 - gsmtp

SMTP server error: 5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 cq6sm24503844pad.30 - gsmtp Message was not sent PHPMailer Error: The following From address failed: wiedeia@gmail.com : MAIL not accepted from server,530,5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 cq6sm24503844pad.30 - gsmtp

SMTP server error: 5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 cq6sm24503844pad.30 - gsmtp

SMTP server error: 5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 cq6sm24503844pad.30 - gsmtp

Debug-Log when using SSL with port 465

SMTP -> FROM SERVER:220 mx.google.com ESMTP kj9sm24304154pbc.37 - gsmtp SMTP -> FROM SERVER: 250-mx.google.com at your service, [121.54.112.183] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8 SMTP -> ERROR: Password not accepted from server: 534-5.7.14 Please log in via your web browser and 534-5.7.14 then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/bin/answer.py?answer=78754 kj9sm24304154pbc.37 - gsmtp SMTP -> FROM SERVER:250 2.1.5 Flushed kj9sm24304154pbc.37 - gsmtp SMTP -> FROM SERVER:530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 kj9sm24304154pbc.37 - gsmtp SMTP -> ERROR: MAIL not accepted from server: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 kj9sm24304154pbc.37 - gsmtp The following From address failed: wiedeia@gmail.com : MAIL not accepted from server,530,5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 kj9sm24304154pbc.37 - gsmtp

SMTP server error: 5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 kj9sm24304154pbc.37 - gsmtp Message was not sent PHPMailer Error: The following From address failed: wiedeia@gmail.com : MAIL not accepted from server,530,5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 kj9sm24304154pbc.37 - gsmtp

SMTP server error: 5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 kj9sm24304154pbc.37 - gsmtp

SMTP server error: 5.5.1 Authentication Required. Learn more at 530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 kj9sm24304154pbc.37 - gsmtp

我在调试时检查了 gmail 提供的链接。但没有任何效果。当我使用相同的用户和密码信息在网络上登录我的帐户时,它起作用了。

我还遵循了我在网上找到的建议,以允许安全性较低的应用程序。我还允许使用链接访问我的 Google 帐户 https://accounts.google.com/DisplayUnlockCaptcha

然后我用端口扫描器检查了端口,两个端口都被提到为关闭。但我想它们会在应用程序请求时打开。使用 telnet smtp.gmail.com 检查成功。

我在没有运行任何防病毒软件和防火墙的情况下也尝试了该脚本——没有结果。

慢慢地,我对这个问题有点生气。可能有人可以在这里帮助我。

安德烈亚斯

最佳答案

Arthur,在不知道正确细节的情况下回答是很愚蠢的。我的意思是,如果您启用了双因素身份验证,则需要设置应用程序专用密码来代替您的电子邮件帐户密码。

您可以按照以下说明生成应用程序专用密码:https://support.google.com/accounts/answer/185833

然后将 $mail->Password 设置为您的应用程序特定密码。

随机变通:有时,我们必须为某些帐户启用两步验证才能正常工作(我不知道背后的正确原因,但这对某些帐户有效)

但从外部来看,这里有一些解决此问题的提示:1) 再次检查 [你说你检查过] 在你的 PHP 上正确配置了 SSL(处理它的模块默认情况下没有安装在 PHP 上。你必须检查你在 pphh.ini 中的配置)。2) 检查您的防火墙是否允许呼出到所需端口(此处为 465 或 587)。使用 telnet 这样做。如果端口未打开,您将需要 sysdmin 的一些支持来设置配置。3)打开这个https://support.google.com/mail/answer/14257?hl=en并选择按照说明进行操作,谷歌服务器会阻止来自未知服务器的任何尝试,因此一旦您点击验证码检查,一切都会好起来的

我希望你能尽快解决这个问题!

关于PHPMailer 不适用于 gmail,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27286783/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com