ruby on rails - Suspicious sign in prevented (Heroku, Amazon AWS, Gmail SMTP)

ID : 274529

viewed : 29

Tags : ruby-on-railsherokusmtpgmailruby-on-rails





Top 5 Answer for ruby on rails - Suspicious sign in prevented (Heroku, Amazon AWS, Gmail SMTP)

vote vote

93

Short Answer

  1. In a web browser (perhaps Chrome/Incognito), log into your Gmail account (the one via which you're trying to send email from your app).

  2. In another browser tab, open https://accounts.google.com/DisplayUnlockCaptcha -- and follow the steps.

Long Answer

I ended up logging into my Gmail account (mentioned as ________@gmail.com in the Stackoverflow question above) and saw the following warning:

enter image description here

[Note: I'm piecing this Answer together after the fact.] Clicking the link Was it you?, I'm pretty sure I was taken to a page that contained the following, though below it there was a message and button about adding another application to the list:

enter image description here

[Again, I'm pretty sure...] Clicking the button on that page brought me to https://accounts.google.com/DisplayUnlockCaptcha -- which looks like this:

enter image description here

Clicking Continue brought me to another page:

enter image description here

At that point I just went to my app, and made it send an email.

Note: for general live-testing of email in my app, I have a view at triggers#index with two buttons that send PUT requests to these actions: triggers#send_email and triggers#raise_exception. This enables an admin to go to /triggers and send an email or raise an exception to test if the production system is working correctly as far as being able to send email is concerned. Raising an exception in any of my apps emails details to me via exception_notification.

vote vote

90

I had the same problem when I tried sending emails through Gmail SMTP using PHP. You shoud complete the troubleshooting steps provided at the end of the email.

vote vote

77

On your Gmail mail box look at the bottom right corner and you can see a Details button. Click on it and then on the pop up window change the suspicious warning settings.

vote vote

63

To get this working in dev with Rails 4 i had to enable access for less secure apps.

Visit https://www.google.com/settings/security/lesssecureapps while signed on to your gmail account and click 'turn on'. Note, this enables access for less secure apps which could come with unintended consequences.

Some apps and devices use less secure sign-in technology, which makes your account more vulnerable. You can turn off access for these apps, which we recommend, or turn on access if you want to use them despite the risks.

vote vote

58

To get this working in Rails 4, in addition to enabling access for less secure apps, as described already (Visit https://www.google.com/settings/security/lesssecureapps while signed on to your gmail account and click 'turn on'. Note, this enables access for less secure apps which could come with unintended consequences.), one more step may be required in some cases, if account access is still blocked. If this is the case, also visit https://accounts.google.com/DisplayUnlockCaptcha and click continue, to enable account access to send via gmail SMTP.

Credit to Steve Polito

Top 3 video Explaining ruby on rails - Suspicious sign in prevented (Heroku, Amazon AWS, Gmail SMTP)







Related QUESTION?