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

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

问题描述

我有一些困难的时候让我的PHP脚本发送邮件与SMTP Gmail帐户。我正在使用PHP和Symfony2 SwiftMailer,但是我的Gmail帐户配置似乎是问题所在。在我的日志中,我最后出现以下错误消息:

 错误 - 刷新电子邮件队列时发生异常:无法验证使用1个可能的身份验证器的用户名new.user.name@gmail.com的SMTP服务器

幸运的是,我有另一个Gmail帐户与另一个应用程序工作,似乎没有。在我的新框中拯救这些参数(用户和密码),eveything工作正常。



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

 参数:
mailer_transport:gmail
mailer_host:〜
mailer_user:old.user.account@gmail.com
mailer_password:旧密码

这里是给出auth错误消息的版本:

 参数:
mailer_transport:gmail
mailer_host:〜
mailer_user:new.user.account@gmail .com
mailer_password:新密码

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



我在新帐户中查看了转发和POP / IMAP下的Gmail帐户设置:我无法找到有关SMTP的信息。 >

搜索让我知道一些验证码策略可能会干扰SMTP帐户。我阅读了此处我应该尝试输入一个验证码短语,我这里,并得到一个好消息:帐户访问启用,请尝试从您的新设备或应用程序重新登录您的Google帐户。



再次尝试。没有运气。



所有这一切都发生在我本地的开发环境(OK邮件和NOT OK邮件)。



如何使用新的Gmail帐户使用SMTP?任何想法 ?

解决方案

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

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

==>我只是要检查:让我的帐户安全不好。 ,并且能够发送邮件。



同时,我发现Gmail SMTP服务变得非常不可靠,并且每隔一段时间引入验证码(这里)。我似乎没有太多可以做的事情。另一方面,在某些情况下,我阅读更强的密码似乎有助于(这里)



我还必须说,通过新创建的帐户,我无法让这个工作。甚至取消选中使我的帐户过度安全选项。真的看起来Gmail正在淘汰其SMTP服务。



更新



我想提到有一些优秀和免费(或非常,非常便宜的大量)替代发送电子邮件。例如,您可以查看 Mandrill SendGrid Amazon SES 等。


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"

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.

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.

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

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."

Trying again. No luck.

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

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

解决方案

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.

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).

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.

UPDATE

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天全站免登陆