symfony1 swift mailer gmail - connection refused

2.7k views Asked by At

I've got a symfony1 application with following factories.yml file:

  mailer:
    param:
      delivery_strategy: realtime
      transport:
        class: Swift_SmtpTransport
        param:
          host:       smtp.gmail.com
          port:       465
          encryption: ssl
          username:   [email protected]
          password:   my_password

password and username is correct, because I can use them to simply log in to gmail. I'm having trouble with symfony/swift mailer using gmail smtp to send mail. I'm submitting correct username/password, but google blocks, saying that the server is in Russia (giving the IP) and it says it doesn't trust it blah blah blah in case this was a security attack. Anyway, it's me and I just want to send emails using gmail.

The original gmail warning-email is in Polish, the translated version goes like this:

Someone recently used your password to log in to your Google Account my.user @ gmail.com. This person has received an application (such as a client e-mail) or mobile device.

We blocked the logon attempt, in case someone wanted to break in to your account. Check out these information:

Thursday, 12 December 2013 8:13:15 UTC IP address: 62.212.65.74 (s99.linuxpl.com.) Location: Russia

If you do not recognize the login attempts, someone else might try to access your account. As soon as you log in and reset your password.

If this is you and you are having trouble accessing your account, follow the troubleshooting instructions available on http://support.google.com/mail?p=client_login

Regards, Google Accounts Team

And the link explains how to use smtp clients just like thunderbird, but it says nothing about software like swift mailer.

The symfony debug environment shows following error code:

Expected response code 250 but got code "530", with message "530-5.5.1 Authentication Required. Learn more at 
530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 a51sm103278568eeh.8 - gsmtp 

Does anyone know what can I do?

2

There are 2 answers

1
ducin On BEST ANSWER

It seems strange, because there's no information about this at mentioned google links, but somehow I managed to find this information on the web:

you may try to visit https://accounts.google.com/DisplayUnlockCaptcha which displays a button that allows this gmail account to be accessed from a distant machine/device (other than the one you're just logged in now). I've pressed the button and retried mail sending and everything works now (the configuration remained 100% the same).

Hope it helps someone.

1
user59191 On

In my case it was a issue with security refer below https://www.google.com/settings/security/lesssecureapps