You should be pretty safe just merging ActionMailer::Base.default_url_options when a URL is required. This will give you preconfigured host and port