Max*_*xxx 8 gmail host smtp ruby-on-rails
我想通过PRODUCTION中的gmail帐户发送电子邮件.它在本地主机上运行良好.
在我的环境中.rb我有:
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "myhost.com",
:authentication => "plain",
:user_name => "name@myhost.com",
:password => "mypassword",
:enable_starttls_auto => true
Run Code Online (Sandbox Code Playgroud)
}
在我的production.rb文件中:
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default_url_options = { :host => 'gmail.com' }
Run Code Online (Sandbox Code Playgroud)
但它没有用,我有这个错误:
Errno::ECONNREFUSED (Connection refused - connect(2)):
Run Code Online (Sandbox Code Playgroud)
有任何想法吗 ?我的应用程序部署在Heroku上.对于host我有什么投入?
谢谢 !
主机应该是www.yourapp.com。我在 Heroku 上的 Gmail 设置如下所示,并且有效:
config.action_mailer.default_url_options = { :host => 'www.myapp.com' }
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:enable_starttls_auto => true,
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:authentication => :login,
:user_name => "user@myapp.com",
:password => "mypassword"
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2900 次 |
| 最近记录: |