eag*_*gor 91 gmail ruby-on-rails ruby-on-rails-3
我正在从我的Rails应用程序发送电子邮件.它在开发环境中运行良好,但在暂存时失败.我收到以下错误:
Net::SMTPAuthenticationError (534-5.7.14 <https://accounts.google.com/ContinueSignIn?plt=AKgnsbtdF0yjrQccTO2D_6)
Run Code Online (Sandbox Code Playgroud)
请注意,我的暂存没有域名.
这是我在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'
}
Run Code Online (Sandbox Code Playgroud)
请帮忙.
编辑.
添加:tls => true选项后,我得到
OpenSSL::SSL::SSLError (Unrecognized SSL message, plaintext connection?)
Run Code Online (Sandbox Code Playgroud)
然后我将端口更改为25,现在我得到了这个(延迟30秒):
Timeout::Error (execution expired)
Run Code Online (Sandbox Code Playgroud)
Gee*_*Bee 240
我遇到了同样的问题:电子邮件是从开发中发送的,但不是来自生产(我在哪里Net::SMTPAuthenticationError).这让我得出结论,问题不是我的应用程序的配置,而是谷歌.
原因:Google阻止了来自未知位置的访问权限(生产中的应用)
解决方案:转到http://www.google.com/accounts/DisplayUnlockCaptcha并单击"继续"(这将为注册新应用授予10分钟的访问权限).在此之后我的生产应用程序开始发送电子邮件;)
A H*_*H K 24
这个解决方案对我有用:
config.action_mailer.delivery_method = :smtp
config.action_mailer.default_url_options = { host:'localhost', port: '3000' }
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default :charset => "utf-8"
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => 'localhost:3000',
:user_name => "xyz@gmail.com",
:password => "password",
:authentication => :plain,
:enable_starttls_auto => true
}
Run Code Online (Sandbox Code Playgroud)
Google确实会阻止您的登录尝试,但您可以通过https://www.google.com/settings/security/lesssecureapps更改设置,以便您的帐户不再受现代安全标准的保护.
eag*_*gor 23
解决了!我只是更改了我的Gmail帐户的密码,不知何故错误消失了.
经过十几次更改后,我最终的最终设置是:
config.action_mailer.delivery_method = :smtp
config.action_mailer.default_url_options = { :host => "my.ip.addr.here" }
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 => :plain,
:enable_starttls_auto => true
}
Run Code Online (Sandbox Code Playgroud)
您可以打开 less secure apps选项(在此处)。
https://myaccount.google.com/lesssecureapps
并解锁验证码(链接): https:
//accounts.google.com/DisplayUnlockCaptcha
| 归档时间: |
|
| 查看次数: |
66925 次 |
| 最近记录: |