使用 Gmail 发送邮件的脚本:无法在 SMTP 服务器上进行身份验证 [英] Script Sending mails with Gmail: Failed to authenticate on SMTP server

查看:100
本文介绍了使用 Gmail 发送邮件的脚本:无法在 SMTP 服务器上进行身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难让我的 PHP 脚本使用 SMTP Gmail 帐户发送电子邮件.我正在使用 PHP 和 Symfony2 SwiftMailer,但似乎问题出在我的 Gmail 帐户配置上.在我的日志中,我最终得到以下错误消息:

I am having some hard time getting my PHP script to send emails with a SMTP Gmail account. I am using PHP and Symfony2 SwiftMailer, but it seems that the problem lies with my Gmail account configuration. In my logs, I end up with the following error message:

"ERROR - Exception occurred while flushing email queue: Failed to authenticate on SMTP server with username "new.user.name@gmail.com" using 1 possible authenticators"

幸运的是,我有另一个 Gmail 帐户与另一个应用程序一起工作,无缝.在我的新盒子上拯救这些参数(用户和密码),一切都很好.

Luckily, I had another Gmail account working with another application, seemlessly. Rescuing these parameters (user and password) on my new box, eveything works just fine.

在 parameters.yml 我有(工作正常):

in parameters.yml I have (working fine):

parameters:
    mailer_transport: gmail
    mailer_host: ~
    mailer_user: old.user.account@gmail.com
    mailer_password: old-password

这是给出身份验证错误消息的版本:

And here is the version giving auth error message:

parameters:
    mailer_transport: gmail
    mailer_host: ~
    mailer_user: new.user.account@gmail.com
    mailer_password: new-password

不用说我已经检查了,重新检查并再次检查了用户和密码.

Needless to say I have checked, rechecked and checked yet again user and password.

我在新帐户的转发和 POP/IMAP"下查看了我的 Gmail 帐户设置:我找不到任何关于 SMTP 的信息.

I reviewed my Gmail account settings under "Forwarding and POP/IMAP" in my new account: I could find nothing about SMTP.

搜索让我意识到某些验证码政策可能会干扰 SMTP 帐户.我在这里读到我应该尝试输入验证码短语,我在here 输入,然后收到很好的消息:帐户访问权限已启用", "请尝试从您的新设备或应用重新登录您的 Google 帐户."

Searches made me aware some captcha policy may interfere with SMTP accounts. I read here that I should try to enter a captcha phrase, which I do here, and get the nice message:"Account access enabled", "Please try signing in to your Google account again from your new device or application."

再试一次.没有运气.

所有这些都发生在我的本地开发环境中(OK 邮件和 NOT OK 邮件).

All this is happening from my local dev environment (both OK mails, and NOT OK mails).

如何通过新创建的 Gmail 帐户使用 SMTP?任何的想法 ?

How I could get to use SMTP with a newly created Gmail Account ? Any idea ?

推荐答案

实际上,我仔细检查了我的收件箱,发现我收到了一封来自 Google 的邮件,说明有人试图进入我的帐户.在那里,我找到了我正在寻找的配置参数的链接:

Actually, double-checking my inbox, I saw I received a mail from Google explaining someone was trying to enter my account. There, I found a link to the configuration parameter I was looking for:

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

==> 我只需要检查:让我的帐户变得不那么安全.",然后就能收到邮件了.

==> I just had to check: "Make my account less secure.", and was able to get mails sent.

与此同时,我发现 Gmail SMTP 服务变得非常不可靠,并且不时引入验证码(此处).我似乎对此无能为力.另一方面,在某些情况下,我阅读更强的密码似乎会有所帮助(此处).

In the mean time, I have found that Gmail SMTP service is getting pretty unrelyable and introduces captcha every now and again (here). I seems there is not much you can do about it. On the other hand, I read stronger passwords seem to help in some cases (here).

我还必须说,使用新创建的帐户,我无法正常工作.甚至取消选中使我的帐户过于安全"选项.看起来 Gmail 确实正在逐步淘汰其 SMTP 服务.

I must also say that with a newly created account, I was not able to get this working. Even unchecking the "make my account overly secure" option. It really looks like Gmail is phasing out its SMTP service.

我想提一下,有一些优秀且免费的(或非常、非常便宜的大量发送电子邮件)替代方案.例如,您可以检查 MandrillSendGridAmazon SES 等.

I wanted to mention that there are some excellent and free (or very, very cheap for high volumes) alternatives for sending emails. For example, you could check Mandrill, SendGrid or Amazon SES, among others.

这篇关于使用 Gmail 发送邮件的脚本:无法在 SMTP 服务器上进行身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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