ruby-on-railssslactionmailersendgrid-rails

Include www subdomain in rails actionmailer urls with Sendgrid


I have a rails 5 app that sends emails using Sendgrid. Those emails have links back into the app, such as <%= link_to "Reply on platform", conversation_url(@conversation) %>.

This all worked fine and dandy, until I added my SSL cert to the site. Now, all of the mailer links point to https://domain.com, instead of simply domain.com. When visiting https://domain.com, the site fails to load and throws an error saying "This site can’t be reached".

This is probably a simply fix that's right under my nose, but I'm having trouble putting my finger on it. Any advice?


Solution

  • Check your mailer configuration in production at config/environments/production.rb.

    Make sure you have or add a line that says: config.action_mailer.default_url_options = {host: "www.domain.com"}