8

PRODUCTION の 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           => "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 にデプロイされています。何hostを入れなければなりませんか?

ありがとう !

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 に答える