Use this code snippet when you need to see the generated HTML by active mailer in the browser.

rails runner 'puts MyMailer.welcome_email("", "Subject").body.to_s' | \
  awk '/<!DOCTYPE.*/,EOF' > test.html && \
  xdg-open test.html
  • MyMailer.welcome_email and its parameters should be changed to match your code
  • Read about Action Mailer if you’re not already familiar with
  • awk command is used to leave out the Rails runner logs
  • Replace xdg-open with open for MacOS