Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么在php中发送邮件时不接受用户名和密码?_Php_Sendmail_Phpmailer - Fatal编程技术网

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

为什么在php中发送邮件时不接受用户名和密码?,php,sendmail,phpmailer,Php,Sendmail,Phpmailer,嗨,这是我的问题: 我想发送邮件,这是我的邮件代码: <?php require "vendor/autoload.php"; class HelperMail{ private $oPhpMailer; function __construct(){ $this->oPhpMailer = new PHPMailer(); $this->oPhpMailer->isSMTP(); $this->

嗨,这是我的问题:

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

<?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!";
                    }

            }
    }
?>
我有一个错误:

我知道用户和pass都可以,所以我不知道问题出在哪里


我怎样才能解决这个问题,如果您收到以下错误,我的英语很抱歉

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帐户凭据是正确的,谷歌的服务器仍然可能会阻止试图进行身份验证的服务器,这很可能是由于新的服务器位置和/或最近的密码更改

要解决此问题,请确保您在浏览器中使用相同的Gmail帐户登录,然后只需打开下面的链接并逐步完成验证过程:

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

SRC:

提示: 您还应该查看url https:/support.google。。。错误后显示。

错误1:密码命令失败:534-5.7.9需要特定于应用程序的密码 答复: 这通常发生在SMTP邮件服务器凭据正确但未提供应用程序特定密码的情况下

错误2:SMTP错误:密码命令失败:535-5.7.8不接受用户名和密码 答复: 如果您遇到此错误,那么这主要是因为特定于应用程序的密码不正确

转到下面的链接


通过选择App Other创建应用程序密码,复制生成的密码并粘贴此密码以代替gmail密码。

允许在谷歌中使用不太安全的应用程序。

在535.7.8了解更多信息https://support.google.com/mail/answer/14257? 你已经看过这个了。。。是吗?…github上的故障排除指南链接得更靠下。很抱歉,我不认为复制和粘贴外包的内容是一个好的答案。我没有投反对票或其他什么,但这主要证明OP没有做出足够的研究努力,因此它的问题是无效的。我同意,OP没有进行足够的研究,因为我在1分钟内找到了答案。只要你提到来源,从不同的网站复制和粘贴答案并不被认为是一种不好的做法。