gpt4 book ai didi

php - 为什么我在 php 中发送邮件时不接受用户名和密码?

转载 作者:行者123 更新时间:2023-12-02 00:57:34 24 4
gpt4 key购买 nike

嗨,这是我的问题:

我想发送邮件,这是我的邮件代码:

<?php

require "vendor/autoload.php";

class HelperMail{

private $oPhpMailer;


function __construct(){

$this->oPhpMailer = new PHPMailer();
$this->oPhpMailer->isSMTP();
$this->oPhpMailer->SMTPDebug = 2;
$this->oPhpMailer->Debugoutput = 'html';
$this->oPhpMailer->SMTPSecure = 'tls';
$this->oPhpMailer->SMTPAuth = true;

}
public function mailFrom($from,$usuario){
$this->oPhpMailer->setFrom($from,$usuario);
}
public function mailPort($puerto){
$this->oPhpMailer->Port = $puerto;
}
public function mailUsuario($usuario){
$this->oPhpMailer->Username = $usuario;
}
public function mailPassword($pass){
$this->oPhpMailer->Password = $pass;
}
public function mailHost($host){
$this->oPhpMailer->Host = $host;
}
public function mailSubject($subject){
$this->oPhpMailer->Subject = $subject;
}
public function mailAddress($address){
$this->oPhpMailer->addAddress($address);
}
public function mailAltBody(){
$this->oPhpMailer->AltBody = 'This is a plain-text message body';
}

public function mailHtml(){

}

public function setData ($usuarios){

$htmlMail = $this->oPhpMailer->msgHTML(file_get_contents('helpers/mailAvisoSinTareasReg/contenido.html'));
$htmlMailChange = str_replace("TRABAJO","LAZOS",$htmlMail);
$this->sendMail();
}


public function sendMail(){

if (!$this->oPhpMailer->send()) {
echo "Mailer Error: " . $this->oPhpMailer->ErrorInfo;
} else {
echo "Message sent!";
}

}
}
?>

我有这个错误:

enter image description here

我知道用户和通行证都正常,所以我不知道问题出在哪里。

我该如何解决这个问题? ,对不起我的英语

最佳答案

如果您收到以下错误:

SMTP -> ERROR:Password not accepted from server. Code: 535 Reply: 535-5.7.1 Please log in with your web browser and then try again.

即使 Gmail 帐户凭据正确,Google 服务器仍可能阻止服务器尝试进行身份验证(很可能是由于新的服务器位置和/或最近更改了密码)。

要解决此问题,请确保您在浏览器中使用同一 Gmail 帐户登录,然后只需打开下面的链接并逐步完成验证过程即可: https://accounts.google.com/b/0/DisplayUnlockCaptcha

这将允许您访问您的 Gmail 帐户大约 10 分钟,以便检测到新的身份验证服务器。请务必在此时间段内再次尝试进行身份验证。”

SRC:http://www.rocketideas.com/2012/05/gmail-error-password-not-accepted-from-server-solved/


提示:您还应该查看错误后显示的网址 (https:/support.google...)。

关于php - 为什么我在 php 中发送邮件时不接受用户名和密码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32846532/

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