发送激活电子邮件,SMTP服务器未接受密码 [英] Sending Activation Email , SMTP server did not accept the password

查看:752
本文介绍了发送激活电子邮件,SMTP服务器未接受密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用CakePHP发送电子邮件,发生错误: SMTP服务器不接受密码,以及收件箱中的电子邮件说:登录尝试被阻止! ,我们最近阻止了您的Google帐户的登录尝试。



是否正常?



我使用Xampp。

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

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

if($ user == false)
{
debug(__ METHOD__。无法检索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').'-请确认您的电子邮件地址';
$ this-> Email-> from ='laurent@gmail.com';
$ this-> Email-> template ='account_verification';
$ this-> Email-> delivery ='smtp';
$ this-> Email-> smtpOptions = array(
'port'=>'465',
'timeout'=> '30',
' host'=>'ssl://smtp.gmail.com',
'username'=>'laurent@gmail.com',
'password'=> 1234567
);
$ this-> Email-> sendAs ='text';
return $ this-> Email-> send();

}


解决方案

在您的Google帐户设置中允许安全性较低的应用:





您应该实现OAuth2,而不是削弱安全性。


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 = 'laurent@gmail.com';
    $this->Email->template = 'account_verification';
    $this->Email->delivery = 'smtp';
    $this->Email->smtpOptions = array(
    'port'=>'465',
    'timeout'=>'30',
    'host' => 'ssl://smtp.gmail.com',
    'username'=>'laurent@gmail.com',
    'password'=>1234567
    );
    $this->Email->sendAs = 'text';  
    return $this->Email->send();

}

解决方案

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

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

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.

这篇关于发送激活电子邮件,SMTP服务器未接受密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆