user2381175
user2381175

Reputation: 29

PHPMailer: Password command failed: 534-5.7.14

function send_mail($message, $subject)
{
    if (array_key_exists('resume', $_FILES))
    {
        $uploadfile = tempnam(sys_get_temp_dir(), sha1($_FILES['resume']['name']));
        if (move_uploaded_file($_FILES['resume']['tmp_name'], $uploadfile))
        {
           require './PHPMailer/PHPMailerAutoload.php';
           $mail              = new PHPMailer;
           $mail->isSMTP();
           $mail->SMTPDebug   = 1;
           $mail->Debugoutput = 'html';
           $mail->Host        = 'smtp.gmail.com';
           $mail->Port        = 587;
           $mail->SMTPSecure = 'tls';            
           $mail->SMTPAuth    = true;
           $mail->Username    = "[email protected]";
           $mail->Password    = "XXXX";
           $mail->SetFrom('[email protected]', 'ABC');
           $mail->AddAddress('[email protected]');
           $mail->Subject = $subject;
           $mail->MsgHTML($message);
           $mail->AltBody = 'This is a plain-text message body';
           $mail->addAttachment($uploadfile);

           if ($mail->Send())
           {
               echo "<script>alert('Your application is sent successfully. Our recruitment team will get in touch with you soon.');</script>";
           }
           else
           {
               echo "Mailer Error: " . $mail->ErrorInfo;

           }
       }
       else
       {
           echo 'Failed to move file to ' . $uploadfile;
       }
   }

}

I am getting below mentioned Error:

CLIENT -> SERVER: EHLO localhost
CLIENT -> SERVER: STARTTLS
CLIENT -> SERVER: EHLO localhost
CLIENT -> SERVER: AUTH LOGIN
CLIENT -> SERVER: ZGV0ZWN0aW9uaW5zdHJ1bWVudEBnbWFpbC5jb20=
CLIENT -> SERVER: ZGV0ZWN0aW9uaW5kaWE=
SMTP ERROR: Password command failed: 534-5.7.14          <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbuk534-5.7.14 PHxasqAG-1Yi0Ij1bFvZdQIBCbXiwU2i-qOUAnhhTN-mHhCHRat1ivgXGVmBuQTk0cJTl2534-5.7.14 7kvt6yrXWWs9R8Rz1mxkje545Mg0F7Xx3Cl1VTW33gDBxGfcVfR-pIVPd1SIqMHWdICkLz534-5.7.14 pPL3_DNms_IS8jJkz3Eo3MH91Yq1OU3XUV1EXzfxaUA7xbYyK9jbwM1XVvVQ-NqqYYKCMY534-5.7.14 uNWA9kWIDl_XXYWrNNP6_cCiWomH8> Please log in via your web browser and534-5.7.14 then try again.534-5.7.14 Learn more at534 5.7.14 https://support.google.com/mail/answer/78754 bb5sm14055457pac.21 - gsmtp

SMTP Error: Could not authenticate. CLIENT -> SERVER: QUIT SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Mailer Error: SMTP connect() failed.

Upvotes: 2

Views: 9010

Answers (2)

Hector Llorens
Hector Llorens

Reputation: 135

I have the same issue but only when trying to connect from heroku. If I try to connect from 000webhost it works with either ssl or tls...

I would prefer not to try with app password strategy (two-factor authentication) but it seems there is nothing else I can try.

Upvotes: 0

Pedro Lobito
Pedro Lobito

Reputation: 98921

You probably need to enable less secure apps


Change account access for less secure apps

To help keep Google Apps users' accounts secure, we may block less secure apps from accessing Google Apps accounts. As a Google Apps user, you will see a "Password incorrect" error when trying to sign in. If this is the case, you have two options:

  1. Option 1: Upgrade to a more secure app that uses the most up to date security measures. All Google products, like Gmail, use the latest security measures.
  2. Option 2: Change your settings to allow less secure apps to access your account. We don't recommend this option because it might make it easier for someone to break into your account. If you want to allow access anyway, follow these steps:

    2.1. Go to the "Less secure apps" section in My Account

    2.2. Next to "Access for less secure apps," select Turn on. (Note to Google Apps users: This setting is hidden if your administrator has locked less secure app account access.)

If you still can't sign in to your account, the "password incorrect" error might be caused by a different reason.

SRC: https://support.google.com/accounts/answer/6010255?hl=en


NOTE:

Add error reporting to the top of your file(s) right after your opening PHP tag for example <?php error_reporting(E_ALL); ini_set('display_errors', 1);

and enable debug on PHPMAILER

$mail->SMTPDebug  = 1; // enables SMTP debug information (for testing)
                       // 1 = errors and messages
                       // 2 = messages only

to see if it yields anything.

Upvotes: 2

Related Questions