php Laravel Gmail 不工作,“不接受用户名和密码。了解更多...”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25249476/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel Gmail not working, "Username and Password not accepted. Learn more..."
提问by user3817533
When I try to send an e-mail through my website running Laravel 4, I get this exception:
当我尝试通过运行 Laravel 4 的网站发送电子邮件时,出现以下异常:
{"error":{"type":"Swift_TransportException","message":"Expected response code 250 but got code \"535\", with message \"535-5.7.8 Username and Password not accepted. Learn more at\r\n535 5.7.8 http:\/\/support.google.com\/mail\/bin\/answer.py?answer=14257 y70sm14744455qgd.3 - gsmtp\r\n\"","file":"\/var\/www\/vendor\/swiftmailer\/swiftmailer\/lib\/classes\/Swift\/Transport\/AbstractSmtpTransport.php","line":386}}
Here is my mail config:
这是我的邮件配置:
return array(
'driver' => 'smtp',
'host' => 'smtp.gmail.com',
'port' => 465,
'from' => array('address' => '[email protected]', 'name' => 'myname'),
'encryption' => 'ssl',
'username' => '[email protected]',
'password' => 'lol',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
);
I've tried the disable link i've found by googling this issue except it didn't make a difference.
我已经尝试了通过谷歌搜索这个问题找到的禁用链接,但它没有任何区别。
Is there a way to tell Google "stop blocking this IP, it's me" ?
有没有办法告诉谷歌“停止阻止这个 IP,是我”?
回答by Pathros
I tried the same thing and got the same error. So i personally checked my gmail account and i had a message from Gmail itself letting me know that they'd blocked an access attempt to my email account.
我尝试了同样的事情并得到了同样的错误。所以我亲自检查了我的 Gmail 帐户,我收到了来自 Gmail 本身的一条消息,让我知道他们阻止了对我的电子邮件帐户的访问尝试。
They showed an option to disable this security setting by visiting https://www.google.com/settings/security/lesssecureapps.
他们通过访问https://www.google.com/settings/security/lesssecureapps显示了禁用此安全设置的选项。
Things will actually be more straight forward if you visit that link already logged in into your Gmail account.
如果您访问该链接已经登录到您的 Gmail 帐户,事情实际上会更直接。
回答by thangngoc89
Go to this link and disable unlock Captcha https://accounts.google.com/b/0/DisplayUnlockCaptcha
转到此链接并禁用解锁验证码 https://accounts.google.com/b/0/DisplayUnlockCaptcha
回答by dilbadil
Try this:
尝试这个:
- Change port to 587
- Goto gmail setting https://www.google.com/settings/security/lesssecureappsand active it.
- 将端口更改为 587
- 转到 gmail 设置https://www.google.com/settings/security/lesssecureapps并激活它。
回答by Ankit Tyagi
https://www.google.com/settings/security/lesssecureappsand active it. https://accounts.google.com/b/0/DisplayUnlockCaptchaand active it.
https://www.google.com/settings/security/lesssecureapps并激活它。 https://accounts.google.com/b/0/DisplayUnlockCaptcha并激活它。
'port' => env('MAIL_PORT', 587), <br>
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
回答by Srinivas
I had lot of issues finding answer for this. Then after doing lot of trial and error i have found an solution to this. Most of the solution above worked for other but it help me upto 50%.
我有很多问题要为此寻找答案。然后经过大量的反复试验,我找到了解决方案。上面的大多数解决方案都适用于其他解决方案,但对我的帮助高达 50%。
So, This is how it worked for me (100%):
所以,这就是它对我的工作方式(100%):
- Activate 2 step Verification in google
- Now you will be able to create app. Open it.
- Create new app (other app) and give your app name.
- Now generate password.
- 在谷歌激活两步验证
- 现在您将能够创建应用程序。打开它。
- 创建新应用程序(其他应用程序)并提供您的应用程序名称。
- 现在生成密码。
Next in laravel, Goto .env file and change
接下来在 Laravel 中,转到 .env 文件并更改
MAIL_USERNAME= 'App Name you created'
MAIL_PASSWORD= 'Generated Password for that app'
This should be able to send emails from your gmail account. Please leave a comment if it doesn't works for you.
这应该能够从您的 Gmail 帐户发送电子邮件。如果它不适合您,请发表评论。
回答by that0n3guy
I know this doesn't answer your question... but I would say don't use gmail for SMTP sending.
我知道这不能回答您的问题……但我会说不要使用 gmail 进行 SMTP 发送。
Use a service like mandrill/mailgun... IE a service that is made for this type of thing. See my mandrill setup here:
使用像 mandrill/mailgun 这样的服务......即为这种类型的东西制作的服务。在这里查看我的山魈设置:
http://laravel.io/forum/07-06-2014-mail-with-mandrill-doesnt-work?page=1#reply-10154
http://laravel.io/forum/07-06-2014-mail-with-mandrill-doesnt-work?page=1#reply-10154
Mandrill gives you 12k emails free per month.
Mandrill 每月免费为您提供 12,000 封电子邮件。
回答by Stasik
Did you activate 2-step google authentification? If so, you need to define a new "application-specific password" password: http://www.google.com/landing/2step/.
您是否激活了两步谷歌身份验证?如果是这样,您需要定义一个新的“应用程序专用密码”密码:http: //www.google.com/landing/2step/。
回答by user11313678
Remove the @gmail.com from username, already you mentioned smtp. So no need @gmail.com on your username. I'm 100% sure it is your problem, because I had that problem.
从用户名中删除@gmail.com,您已经提到了smtp。所以你的用户名不需要@gmail.com。我 100% 肯定这是你的问题,因为我有那个问题。