简体   繁体   English

Google为什么拒绝我的Ruby on Rails应用中的电子邮件?

[英]Why is google rejecting emails from my Ruby on Rails app?

I'm using ruby on rails to send some emails: 我正在使用ruby on rails发送一些电子邮件:

I wanted to test ActionMailer with my personal gmail account, from my console. 我想从控制台通过个人Gmail帐户测试ActionMailer。 however google is displaying the following errors: 但是谷歌显示以下错误:

Sign-in attempt was blocked 登录尝试被阻止

Someone just used your password to try to sign in to your account from a non-Google app. 有人刚刚使用您的密码尝试通过非Google应用登录您的帐户。 Google blocked them, but you should check what happened. Google阻止了它们,但是您应该检查发生了什么。 Review your account activity to make sure no one else has access. 查看您的帐户活动,以确保没有其他人可以访问。 Check 校验

I used to be able to just use any of the answers from these questions: 我以前只能使用以下问题的任何答案:

Can't send email using Gmail on Heroku 无法在Heroku上使用Gmail发送电子邮件

Can't send mail with gmail stmp server (in discourse) 无法通过Gmail Stmp服务器发送邮件(在讨论中)

why is devise not sending email via gmail smtp? 为什么devise不通过gmail smtp发送电子邮件?

But now I just can't send emails using my google account. 但是现在我无法使用我的Google帐户发送电子邮件。

What changed? 发生了什么变化? How do I configure my gmail to be able to do this? 如何配置我的Gmail才能做到这一点?

This is the code I run from my console: 这是我从控制台运行的代码:

ActionMailer::Base.delivery_method = :smtp 
ActionMailer::Base.smtp_settings = {
  address:              'smtp.gmail.com', 
  port:                 587, 
  domain:               'gmail.com',
  authentication:       'plain', 
  enable_starttls_auto: true, 
  user_name:            'some@gmail.com',
  password:             '********'
}

mailer = ActionMailer::Base.new

# send mail:
mailer.mail(from: 'some@gmail.com', to: 'some_other@gmail.com', subject: 'test', body: "Hello, you've got mail!").deliver

您可以使用您的Google帐户启用两要素身份验证,并写下他们给您的代码(上次我检查了他们给了您的密码中的大约10个),然后在发送电子邮件时使用这些代码之一对您的Rails应用程序进行身份验证您的帐户密码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM