php – Failed to authenticate password using codeigniter-ThrowExceptions

Exception or error:

Failed to authenticate password. Error: 534-5.7.14 Please log in via your web browser and then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/bin/answer.py?answer=78754 wv1sm5867206pab.37 – gsmtp

function index() {

     $config = Array(
       'protocol' => 'smtp',
       'smtp_host' => 'ssl://smtp.googlemail.com',
       'smtp_port' => 465,
       'smtp_user' => 'gauravkwt@gmail.com',
       'smtp_pass' => '92135108845129',
       'mailtype' => 'html',
       'charset' => 'iso-8859-1',
       'wordwrap' => TRUE  

     );

     $this->load->library('email', $config);
     $this->email->set_newline("\r\n");
     $this->email->from('gauravkwt@gmail.com', 'Gaurav kwatra');
     $this->email->to('gaurav.kawatra@ymail.com');
     $this->email->subject('This is an email test');
     $this->email->message('Emial Testing');

      //$this->email->initialize($config);

     if($this->email->send())
     {
         echo 'Your email sent...!!!! ';
     }
     else 
     {
         show_error($this->email->print_debugger());
     }
 }
//end of code

I use above code to send mail from codeigniter….I have an error…Failed to authenticate. Password is correct.

How to solve:

You would need to go to your account settings https://www.google.com/settings/security and you would need to enable Access for less secure apps which helps to use the google smtp for clients.

Please have a look here too

Answer:

If it still doesn’t work even after enabling less secure apps – you should login to your security area within your Google account and see if your device has been blocked. Google blocked my server so I then went to https://accounts.google.com/b/0/displayunlockcaptcha and it now allows me to send. Nothing to do with the username or password but Google blocking the device access.

Answer:

One of the reason can be the cpanel settings. Please try:

  1. Login to CPanel
  2. Tweak Settings > All>
  3. “Restrict outgoing SMTP to root, exim, and mailman (FKA SMTP Tweak)

And select “off”

Answer:

Although it was a question five years ago, today I encountered the same situation and found the correct answer as a supplement.

All CI settings are correct, the only problem lies in Google ’s security settings, go to

https://myaccount.google.com/security

And set Sign in using App Passwords, which can find options, select mail, and choose other in the options of the device, enter the name at will, such as PHP / CI, and then Google will generate a password for you to use.
Please replace the password you entered in the CI email with this password, cheers.

Leave a Reply

Your email address will not be published. Required fields are marked *