Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending Activation Email , SMTP server did not accept the password

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();

}
like image 469
Exchanger13 Avatar asked Oct 16 '14 08:10

Exchanger13


People also ask

What is my SMTP server password?

Gmail SMTP username: Your full Gmail address, such as [email protected]. Gmail SMTP password: Your Gmail password.

How do I fix Gmail SMTP error?

In Google Mail, you must allow "less secure" apps access in order for your SMTP settings to work. There are two places this setting must be enabled: The first is here: https://myaccount.google.com/ under “Connected apps & sites.” Once enabled in both places, you're good to go!


2 Answers

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!

like image 103
floriank Avatar answered Oct 10 '22 10:10

floriank


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.

like image 22
nosnevetzy Avatar answered Oct 10 '22 11:10

nosnevetzy