Skip to content

How To: Send emails from subdomains

trevorturk edited this page Sep 20, 2010 · 8 revisions

Devise sends registration confirmations, forgotten password messages, and other email messages. These will originate from the main domain by default, but you can modify the application so these emails originate from subdomains.

Add the following code to the file app/helpers/url_helper.rb:

def set_mailer_url_options
  ActionMailer::Base.default_url_options[:host] = with_subdomain(request.subdomain)
end

and modify the file app/controllers/application_controller.rb to add:
before_filter :set_mailer_url_options

This information is provided from http://github.com/fortuity/rails3-subdomain-devise/blob/master/TUTORIAL.textile and Thanks to Tom Howlett for this contribution.

Clone this wiki locally