无法发送SMTP邮件PHPMailer

时间:2019-08-01 06:52:37

标签: php smtp phpmailer

好吧,我在核心PHP上开发了一个通用项目,其中包括邮件系统。一所大学的代表在其大学进行注册,并向我的帐户发送了一封邮件,以调查是否给予演示或高级门户所有权。然后整个过程继续。 我差不多一年前就已经部署了它,而且我工作得很好。但是今天我从存储库

克隆了它

https://github.com/TheAkif/alumni-portal

并在localhost上运行它,它没有发送电子邮件并给我这些错误:

    2019-08-01 06:01:12 CLIENT -> SERVER: AUTH LOGIN
    2019-08-01 06:01:12 SERVER -> CLIENT: 334 VXNlcm5hbWU6
    2019-08-01 06:01:12 CLIENT -> SERVER: <credentials hidden>
    2019-08-01 06:01:12 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
    2019-08-01 06:01:12 CLIENT -> SERVER: <credentials hidden>
    2019-08-01 06:01:13 SERVER -> CLIENT: 535-5.7.8 Username and Password not 
    accepted. Learn more at535 5.7.8 https://support.google.com/mail/? 
    p=BadCredentials f204sm108618451wme.18 - gsmtp
    2019-08-01 06:01:13 SMTP ERROR: Password command failed: 535-5.7.8 
    Username and Password not accepted. Learn more at535 5.7.8 
    https://support.google.com/mail/?p=BadCredentials f204sm108618451wme.18 - 
    gsmtp
    SMTP Error: Could not authenticate.
    2019-08-01 06:01:13 CLIENT -> SERVER: QUIT
    2019-08-01 06:01:13 SERVER -> CLIENT: 221 2.0.0 closing connection 
    f204sm108618451wme.18 - gsmtp
    SMTP Error: Could not authenticate.

mailer.php看起来像这样。

    // Import PHPMailer classes into the global namespace
    // These must be at the top of your script, not inside a function
    use PHPMailer\PHPMailer\PHPMailer;
    use PHPMailer\PHPMailer\Exception;
    //Load Composer's autoloader
    require 'vendor/autoload.php';
    $mail = new PHPMailer(true);                              
    try {
        //Server settings
        $mail->SMTPDebug = 2;                                
        $mail->isSMTP();                                      
        $mail->Host = 'smtp.gmail.com';                       
        $mail->SMTPAuth = true;                               
        $mail->Username = 'zyx@gmail.com';                
        $mail->Password = 'xxxxxxxxxx';                   
        $mail->SMTPSecure = 'tls';                        
        $mail->Port = 587;                                
        $mail->setFrom('zyx@gmail.com', 'Portal');
        $mail->addAddress('xyz@gmail.com', 'Something');
        $mail->isHTML(true);                                   
        $mail->Subject = 'Here is the subject';
    }

0 个答案:

没有答案