Script Sending mails with Gmail: Failed to authenticate on SMTP server

前端 未结 3 1568
清歌不尽
清歌不尽 2021-01-02 03:57

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

相关标签:
3条回答
  • 2021-01-02 04:17

    Using the link https://www.google.com/settings/security/lesssecureapps gave me the message: this setting is disabled by your administrator.

    I had to go to admin.google.com and login with the same account details and look for the same setting there. Full url was https://admin.google.com/AdminHome#ServiceSettings/notab=1&service=securitysetting&subtab=lesssecureappsaccess

    Then the first link worked, so also there I enabled less secure apps. Now I was able to use Gmails SMTP.

    0 讨论(0)
  • 2021-01-02 04:22

    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.

    0 讨论(0)
  • 2021-01-02 04:35

    Maybe this helps someone: I had the same encounter with gmail, but in my case, when I logged into the gmail account that I configured in my code as SMTP mail sender user, I was greeted by a warning message saying that somebody tried to use my user and pass and that attempt was blocked (hence my error message). It asked me to confirm if that was me or not, so after I clicked the 'That was me' button and tried my code again all worked fine.

    0 讨论(0)
提交回复
热议问题