2012-04-24 15 views
8

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の場合はどうすればいいですか?

ありがとうございます!

+0

これに答えがあったら本当に知りたいです。 –

答えて

2

ホストはwww.yourapp.comである必要があります。ヘロクの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

関連する問題