Net :: SMTPAuthenticationError从Rails应用程序发送电子邮件时(在分段环境中) [英] Net::SMTPAuthenticationError when sending email from Rails app (on staging environment)

查看:265
本文介绍了Net :: SMTPAuthenticationError从Rails应用程序发送电子邮件时(在分段环境中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从Rails应用程序发送电子邮件。它在开发环境中运行良好,但在分段时失败。我收到以下错误:

  Net :: SMTPAuthenticationError(534-5.7.14< https://accounts.google。 com / ContinueSignIn?plt = AKgnsbtdF0yjrQccTO2D_6)

请注意,我没有域名

这是我在staging.rb中的设置

  config.action_mailer.delivery_method =:smtp 
config.action_mailer.default_url_options = {:host => my.ip.addr.here:80}
config.action_mailer.smtp_settings = {
:address => smtp.gmail.com,
:port => 587,
:domain => 'my.ip.addr.here:80'
:user_name => my_email_name@gmail.com,
:password => my_email_password,
:authentication => 'login'
}

请帮助。

编辑



在添加:tls =>真正的选项我得到

  OpenSSL :: SSL :: SSLError(无法识别的SSL消息,明文连接? )

然后我将端口改为25,现在我得到了这个(延迟30秒):

  Timeout :: Error(执行过期)


解决方案

我遇到了同样的问题:电子邮件是从开发中发出的,但不是来自生产(我得到 Net :: SMTPAuthenticationError )。
这促使我得出结论:问题不在于我的应用程序的配置,而在于Google。



原因:Google阻止从未知位置访问(应用在制作中)



解决方案:转到 http://www.google.com/accounts/DisplayUnlockCaptcha ,然后点击继续(这将授予访问10分钟以注册新应用程序)。
在此之后,我的应用程序开始发送电子邮件;)


I am sending email from my Rails application. It works well on development environment, but fails on staging. I get the following error:

Net::SMTPAuthenticationError (534-5.7.14 <https://accounts.google.com/ContinueSignIn?plt=AKgnsbtdF0yjrQccTO2D_6)

Note, that my I don't have a domain name for my staging.

Here are my settings in staging.rb

config.action_mailer.delivery_method = :smtp
config.action_mailer.default_url_options = { :host => "my.ip.addr.here:80" }
config.action_mailer.smtp_settings = {
      :address => "smtp.gmail.com",
      :port => 587,
      :domain => 'my.ip.addr.here:80'
      :user_name => "my_email_name@gmail.com",
      :password => "my_email_password",
      :authentication => 'login'
}

Please, help.

Edit.

After adding :tls => true option I get

OpenSSL::SSL::SSLError (Unrecognized SSL message, plaintext connection?)

And then I changed port to 25 and now I get this (with 30 seconds delay):

Timeout::Error (execution expired)

解决方案

I had the same problem: emails were sent from development, but not from production (where I was getting Net::SMTPAuthenticationError). This drove me to conclusion that the problem was not with my app's configuration, but with Google.

Reason: Google was blocking access from unknown location (app in production)

Solution: Go to http://www.google.com/accounts/DisplayUnlockCaptcha and click continue (this will grant access for 10 minutes for registering new apps). After this my app in production started sending emails ;)

这篇关于Net :: SMTPAuthenticationError从Rails应用程序发送电子邮件时(在分段环境中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆