title: How to set the ActionMailer default_url_options's :host dynamically to the request's hostname?
body: <p>I am trying to set the :host for action mailer default url options.</p>
  
  <p>I have the below set in all the environment files</p>
  
  <pre><code>config.action_mailer.default_url_options = {
    :host =&gt; "localhost"
  }
  </code></pre>
  
  <p>I want to make it more dynamic by providing the request host.</p>
  
  <p>when I try to set it by </p>
  
  <pre><code>config.action_mailer.default_url_options = {
    :host =&gt; request.domain
  }
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>config.action_mailer.default_url_options = {
    :host =&gt; request.env["SERVER_NAME"]
  }
  </code></pre>
  
  <p>It throws error... doesn't recognize "request" object</p>
  
  <p>is there any way I can set this to the request host, not by hardcoding...?</p>