Ich habe eine Anwendung mit Rails 3 erstellt und ich habe eine einfache Kontaktseite erstellt, um E-Mails über meinen SMTP-Server zu senden. Das Problem ist, meine App kann Mail senden, wenn ich es in meinem lokalen Host (mein PC) ausführen, aber es funktioniert nicht, wenn ich die App auf dem Hosted Server (Hostgator) ausführen. Das lustige Zeug ist, dass der SMTP-Server der gleiche ist! ActionMailer funktioniert auf localhost aber nicht auf einem öffentlichen Server
Dies ist die config in meinem localhost (und es funktioniert!):
config/Umgebungen/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"
config/initializers/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
}
Die URL für meinen Host-Server ist app.mydomain.org, also in der gehosteten App habe ich nur diese geändert :
config/Umgebungen/development.rb
# ActionMailer Config
config.action_mailer.default_url_options = { :host => 'mydomain.org' }
...
In dem Host-Server für nur jetzt habe ich die App mit WEBrick im Entwicklungsmodus laufen. Und ich bekomme einen Timeout-Fehler:
....
Timeout::Error (execution expired):
app/controllers/contact_us_controller.rb:13:in `create'
...
Am I somenthing fehlt ??
EDIT & GELÖST:
Hostgator Support-Mitarbeiter haben gerade die Ursache für dieses Problem erfahren. In der ActionMailer
Konfiguration muss :address
localhost
und nicht mail.mydomain.org
sein. So würde der ActionMailer sein:
Vielleicht blockiert Hostgator den SMTP-Port? –
Wenn es so wäre, würde es nicht funktionieren, wenn ich die App in meinem PC laufen lasse, oder? –
Ich denke nur laut :) –