Missing host to link to! Please provide :host parameter

If you’ve followed my version of the authlogic account activation tutorial or the original version by Matt Hooks you might have run into this error:

Missing host to link to! Please provide :host parameter or set default_url_options[:host] when sending emails

When authlogic sends e-mails with the account activation link, it uses a url_for helper to build that link. Because the “Notifier” mailer is an instance of ActionMailer::Base and not ActionController::Base it doesn’t know what the host parameter of the URL should be, so you have to tell it explicitly.

Put the following into your environments/development.rb and environments/test.rb:

# This assumes you're running your local development server on port 3000 via script/server
config.action_mailer.default_url_options = { :host => "" }

Put this into your environments/production.rb:

# Replace example.org with your actual domain name
config.action_mailer.default_url_options = { :host => "example.org" }



Leave a Reply

Your email address will not be published. Required fields are marked *