繁体   English   中英

为什么我用php发邮件收不到用户名和密码?

[英]Why Username and Password not accepted when I send mail in php?

嗨,这是我的问题:

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

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

            }
    }
?>

我有这个错误:

在此处输入图像描述

我知道用户和通行证都可以,所以我不知道是什么问题。

我怎样才能解决这个问题? , 对不起我的英语不好

如果您收到以下错误:

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/


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

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

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

转到以下链接https://support.google.com/accounts/answer/185833?hl=en

通过选择应用程序(其他)创建应用程序密码并复制生成的密码并将此密码粘贴到 gmail 密码的位置。

允许在 google 中使用安全性较低的应用程序。 https://myaccount.google.com/lesssecureapps

允许您的 gmail 帐户less secure app access

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM