Sending Activation Email , SMTP server did not accept the password
Asked Answered
N

3

17

I'm sending an email using CakePHP and I got an Error: SMTP server did not accept the password, along with an email in my inbox says that: sign-in attempt blocked! , we recently blocked a sign-in attempt to your Google Account.

Is that normal?

I'm using Xampp.

function sendActivationEmail($user_id)    
{   
    Debugger::dump($user_id);

    $user = $this->User->findById($user_id);

    if ($user==false) 
    {
        debug(__METHOD__." failed to retrieve User data for user.id: {$user_id}");
        return false;
    } 
    $this->set('username', $this->data['User']['username']);
    $this->Email->to = $user['User']['email'];
    $this->Email->subject = env('SERVER_NAME').'- Please confirm your email address';
    $this->Email->from = '[email protected]';
    $this->Email->template = 'account_verification';
    $this->Email->delivery = 'smtp';
    $this->Email->smtpOptions = array(
    'port'=>'465',
    'timeout'=>'30',
    'host' => 'ssl://smtp.gmail.com',
    'username'=>'[email protected]',
    'password'=>1234567
    );
    $this->Email->sendAs = 'text';  
    return $this->Email->send();

}
Nea answered 16/10, 2014 at 8:3 Comment(6)
can you post your here code?Vickery
I've added the code up there ,what could be wrong ?Nea
try to insert your password in ''. like this '123456' are you using localhost? sometimes email() is not working in other version of xampp.Vickery
I've tried that before , and yes I'm using localhost but mostly its a gmail security issue as <burzum> has mentionedNea
yeah, I forgot that google function to mention. haha! good luck. (y)Vickery
Use another username and password only to check.Claim
P
35

You need to allow "less secure" apps in your Google account settings:

https://www.google.com/settings/security/lesssecureapps

enter image description here

See this announcement as well http://googleonlinesecurity.blogspot.de/2014/04/new-security-measures-will-affect-older.html

You should implement OAuth2 instead of weakening the security!

Price answered 16/10, 2014 at 8:24 Comment(4)
I'm still getting :SMTP server did not accept the password. even after setting Access for less secure apps to EnableNea
@Nea I'm getting the same thing, did you find a solution?Halla
This did the job! accounts.google.com/b/0/DisplayUnlockCaptcha and click the button 'Continue'.Cosmotron
I know I am quite late to the party, but, does anyone know the reasons why an app may be identified as a "less secure app?"Fissiparous
E
13

Make sure that the field in 'username' => and 'password'=> is authenticate or valid. I had experienced the same issue and all I do is to go this link https://accounts.google.com/b/0/DisplayUnlockCaptcha and click the button 'Continue'. make sure you're logged in in gmail using the 'username' and 'password' provided in your code. After that, try to send email again.

Etz answered 20/2, 2015 at 14:45 Comment(5)
Nice. Worked for me.Parakeet
Worked for me too. Thanks!Pus
I'm still getting the error SMTP server did not accept the password. . any idea about that?Steatopygia
Work for me Thank you for saving my timeRayshell
Note that if you are logged in to multiple Gmai/Google accounts you may have to visit the specific page for the user. For example I was doing for number 2 user so I had to replace 0 with 2 in the url to make it accounts.google.com/b/2/DisplayUnlockCaptchaSiouan
E
1

I was facing same issue. in my case Password was not so strong. It contains username in password. I change the password and try again. it works. *The other thing you can do that you can use other email address with strong password. make sure captcha is and less secure is enabled. *

https://accounts.google.com/b/0/DisplayUnlockCaptcha

Experimental answered 7/2, 2020 at 4:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.