ruby-on-rails – Rails:在生产中通过Gmail发送电子邮件

我想通过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

}

在我的production.rb文件中:

config.action_mailer.raise_delivery_errors = true
config.action_mailer.default_url_options = { :host => 'gmail.com' }

但它没有用,我有这个错误

Errno::ECONNREFUSED (Connection refused - connect(2)):

有任何想法吗 ?我的应用程序部署在Heroku上.
对于主持人我需要放什么?

谢谢 !

解决方法

主持人应该是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"
}

相关文章

validates:conclusion,:presence=>true,:inclusion=>{...
一、redis集群搭建redis3.0以前,提供了Sentinel工具来监控各...
分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣...
上一篇博文 ruby传参之引用类型 里边定义了一个方法名 mo...
一编程与编程语言 什么是编程语言? 能够被计算机所识别的表...
Ruby类和对象Ruby是一种完美的面向对象编程语言。面向对象编...