问题
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.
回答1:
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
回答2:
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.
回答3:
One of the reason can be the cpanel settings. Please try:
- Login to CPanel
- Tweak Settings > All>
- "Restrict outgoing SMTP to root, exim, and mailman (FKA SMTP Tweak)
And select "off"
回答4:
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.
回答5:
I have got the same problem and the solution I found by unblocking the google captcha. Google blocked my server IP sending email using their SMTP. So I had to unblock it.
To unblock the google captche:
- Open the link https://accounts.google.com/DisplayUnlockCaptcha.
- Enter your username and password to sign in to your gmail account that you have used for the SMTP configuration.
You will get the button on google like the image bellow.
- Then you need to allow access to your google account by clicking the continue button.
Note: You might get blocked again and anytime if you make some spam and your receiver email addresses are not exist.
So if anyone knows how to make it unblock permanently without by any google setting or something, it would be really appreciated.
来源:https://stackoverflow.com/questions/26193464/failed-to-authenticate-password-using-codeigniter