为什么 google 在 Rails 应用程序上拒绝来自我的 Ruby 的电子邮件?
Why is google rejecting emails from my Ruby on Rails app?
我在 rails 上使用 ruby 发送一些电子邮件:
我想从我的控制台用我的个人 gmail 帐户测试 ActionMailer。但是 google 显示以下错误:
Sign-in attempt was blocked
Someone just used your password to try to
sign in to your account from a non-Google app. Google blocked them,
but you should check what happened. Review your account activity to
make sure no one else has access. Check
我过去只能使用这些问题的任何答案:
Can't send mail with gmail stmp server (in discourse)
why is devise not sending email via gmail smtp?
但现在我无法使用我的 google 帐户发送电子邮件。
发生了什么变化?如何配置我的 gmail 才能执行此操作?
这是我 运行 来自我的控制台的代码:
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申请时发送e-mail而不是您的账户密码。
我在 rails 上使用 ruby 发送一些电子邮件:
我想从我的控制台用我的个人 gmail 帐户测试 ActionMailer。但是 google 显示以下错误:
Sign-in attempt was blocked
Someone just used your password to try to sign in to your account from a non-Google app. Google blocked them, but you should check what happened. Review your account activity to make sure no one else has access. Check
我过去只能使用这些问题的任何答案:
Can't send mail with gmail stmp server (in discourse)
why is devise not sending email via gmail smtp?
但现在我无法使用我的 google 帐户发送电子邮件。
发生了什么变化?如何配置我的 gmail 才能执行此操作?
这是我 运行 来自我的控制台的代码:
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申请时发送e-mail而不是您的账户密码。