Rails:在生产中通过Gmail发送电子邮件
问题描述:
我想通过PRODUCTION中的我的Gmail帐户发送电子邮件。它在当地主机很好用。Rails:在生产中通过Gmail发送电子邮件
在我的environment.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 => "[email protected]",
: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上。 对于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 => "[email protected]",
:password => "mypassword"
}
+1
谢谢您的回答,但它对我无效:-( – Maxxx 2012-04-25 08:37:36
如果你有这个答案,我真的很想知道。 – 2013-03-11 18:03:06