How to use an email layout with Devise

To use a custom email layout with Rails 5 and Devise, open config/initializers/devise.rb and add this line:

# Use layouts for Devise
Devise::Mailer.layout "mylayout"

Then, add a new file to app/views/layouts called mylayout.html.erb:

<!DOCTYPE html>
<html>
<head></head>
<body>
<%= yield %>
</body>
</html>

Of course, you can change mylayout in both the Devise config and filename if you’d like to call it something different.

Remember to restart your server before testing this.

I'm Mark Thomas Miller, an engineer, designer, and maker of things.