在2022年5月30日的上,谷歌改变了“安全程度较低的应用程序”设置,不再可用。
为了保护你的帐户安全,从2022年5月30日起,Google不再支持使用第三方应用程序或设备,这些应用程序或设备要求您仅使用用户名和密码登录Google帐户。
由于这个原因,我无法使用PHP在本地主机上发送电子邮件。
还有别的办法吗?
发布于 2022-06-14 12:16:26
我将假设您通过smtp服务器连接到Gmail。
如果您当前使用的gmail帐户的实际密码,您要连接到。最好的做法是尝试创建一个应用程序密码并使用它。
$mail->SMTPDebug = SMTP::DEBUG_SERVER; //Enable verbose debug output
$mail->isSMTP(); //Send using SMTP
$mail->Host = 'smtp.example.com'; //Set the SMTP server to send through
$mail->SMTPAuth = true; //Enable SMTP authentication
$mail->Username = 'user@example.com'; //SMTP username
$mail->Password = 'APPsPassword'; //New apps password
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption
$mail->Port = 465; 另一种选择是切换到西奥斯或再次使用Oauth2切换到Gmail。
$mail->oauthUserEmail = "[Redacted]@gmail.com";
$mail->oauthClientId = "[Redacted]";
$mail->oauthClientSecret = "[Redacted]";
$mail->oauthRefreshToken = "[Redacted]";https://stackoverflow.com/questions/72616576
复制相似问题