Permalink
Browse files

Fixed action_mailer routing settings. Issue #219

  • Loading branch information...
1 parent c95dd38 commit 64171e165e3c2eff6ee6c4587f128163cb9c60f3 @steveyken steveyken committed Dec 27, 2012
Showing with 12 additions and 9 deletions.
  1. +10 −8 config/initializers/action_mailer.rb
  2. +2 −1 config/settings.default.yml
@@ -1,15 +1,17 @@
+#
# Configure ActionMailer unless running tests
-
+# ActionMailer is setup in test mode later on
+#
unless Rails.env.test?
- # Set SMTP settings if present.
+
smtp_settings = Setting.smtp || {}
+
if smtp_settings["address"].present?
- Rails.application.config.action_mailer.delivery_method = :smtp
- Rails.application.config.action_mailer.smtp_settings = smtp_settings
+ Rails.application.config.action_mailer.smtp_settings = smtp_settings.symbolize_keys
+ end
+
+ if (host = Setting.host).present?
+ (Rails.application.routes.default_url_options ||= {})[:host] = host.gsub('http://', '')
end
-end
-# Set default host for outgoing emails
-if Setting.host.present?
- (Rails.application.config.action_mailer.default_url_options ||= {})[:host] = Setting.host
end
@@ -49,7 +49,7 @@
# incoming request, so you’ll need to provide all of the details needed to
# generate a URL.
#
-# :host: "http://www.example.com"
+# :host: "www.example.com"
#
:host: ""
@@ -84,6 +84,7 @@
:authentication : :plain
:user_name : ""
:password : ""
+# :delivery_method : :smtp # This is the default. Can be :smtp, :sendmail, :test, :file
# Settings for the Email dropbox (IMAP)

0 comments on commit 64171e1

Please sign in to comment.