为什么我用php发送邮件时不接受用户名和密码? [英] Why Username and Password not accepted when I send mail in php?

查看:127
本文介绍了为什么我用php发送邮件时不接受用户名和密码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的问题:

我要发送邮件,这是我的电子邮件代码:

I want send a mail and this is my mail code:

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

            }
    }
?>

我遇到此错误:

我知道用户和通行证都可以,所以我不知道出了什么问题.

I know that the user and pass are ok , so i don't know what is the problem.

我该如何解决? ,对不起我的英语

How can I fix this? , sorry for my english

推荐答案

如果收到以下错误:

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的服务器仍可能阻止该服务器进行身份验证(很可能是由于新服务器位置和/或最近更改了密码).

Even if the Gmail account credentials are correct, Google’s servers may still block the server attempting to authenticate (more than likely due to a new server location and/or recent password change).

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

To get around this, make sure you are logged in using the same Gmail account in your browser, and then simply open the link below and step through the process of verification: https://accounts.google.com/b/0/DisplayUnlockCaptcha

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

This will allow access to your Gmail account for about 10 minutes so that a new authenticating server can be detected. Be sure to try authenticating again within this time period."

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

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

TIP: You should also take a look at the url (https:/support.google...) presented after the error.

这篇关于为什么我用php发送邮件时不接受用户名和密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆