私はRails 3でアプリケーションを構築しました。私はSMTPサーバー経由でメールを送るための簡単な連絡先ページを作成しました。 問題は、私のローカルホスト(私のPC)でアプリケーションを実行するとメールを送信できますが、ホストされたサーバー(hostgator)でアプリケーションを実行すると動作しません。 面白いことに、smtpサーバーは同じです!ActionMailerはlocalhost上で動作しますが、公開サーバにはありません
これは私のローカルホストで設定(およびそれが動作!)です:
設定/環境/ developer.rb
# ActionMailer Config
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default :charset => "utf-8"
設定/初期化子/ setup_mail.rb
ActionMailer::Base.smtp_settings = {
:address => "mail.mydomain.org",
:port => 26,
:domain => "app.mydomain.org",
:user_name => "[email protected]",
:password => "********",
:authentication => "plain",
:enable_starttls_auto => false
}
私のホストサーバーのURLはapp.mydomain.orgなので、ホストされているアプリケーションではこれを変更しました:
設定/環境/ development.rbホストサーバで
# ActionMailer Config
config.action_mailer.default_url_options = { :host => 'mydomain.org' }
...
は、ちょうど今の私は、開発モードでWEBrickにしてアプリを実行します。 そして、私はタイムアウトエラーを取得:
....
Timeout::Error (execution expired):
app/controllers/contact_us_controller.rb:13:in `create'
...
私はsomenthingをしないのです??
EDIT解決しよう&:
Hostgatorのサポートスタッフは、ちょうどこの問題の原因を見つけてきました。 ActionMailer
の設定では、:address
はlocalhost
でなければならず、mail.mydomain.org
でなければなりません。したがって、ActionMailerは次のようになります。
おそらくHostgatorがSMTPポートをブロックしていますか? –
もしそうなら、私は自分のPCでアプリを実行するとうまくいかないでしょうか? –
ちょっと考えました:) –