Send email with Google account using CodeIgniter

2019-07-15 10:26发布

问题:

I'm trying to send emails with CodeIgniter using smtp.googlemail.com. No problems with code but Google is preventing me from sending that email - here's the email I received on my Google account:

A third party recently tried to use an application to connect to your Google account.

We blocked the connection attempt in case it would be a hacker trying to access your account.

If you have not made ​​this connection attempt, it may mean a third party is trying to access your account. We recommend that you log into your account and reset your password immediately. We blocked the connection attempt in case it would be a hacker trying to access your account.

If this is your account and if you are having trouble to get there, follow the troubleshooting procedure explained at http://support.google.com/mail?p=client_login.

I have followed the link and didn't find a solution.

回答1:

I have the same issue, got an email from Google saying "Sign-in attempt prevented" when I was trying the same. I am ignoring what you have received from google and the text of email. Finally I solved the issue to send mail using CodeIgniter Email library today.

To use Google SMTP in CodeIgniter you need to make 2 (two) changes into Gmail account setting: (N.B. Please be aware that it is now easier for an attacker to break into your account -says Google)

  1. Set off 2-step Verification.
  2. Allow less secure apps: ON (or Enable)

Now use 'smtp_host' as ssl://smtp.gmail.com instead of smtp.googlemail.com

Hope this help.