8

I want to send email via my gmail account in PRODUCTION. It works great in local host.

In my environment.rb I have :

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

}

And in my production.rb file :

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

But it doesn't work and I have that error :

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

Any ideas ? My app is deployed on Heroku. For the host what do I have to put ?

Thanks !

4

1 回答 1

2

主机应该是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"
}
于 2012-04-24T01:19:12.687 回答