Missing template layouts/mailer with {:locale=>[:en], :formats=>[:html],

The issue is the next:

to generate this mailer you use this command

$rails generate mailer UserMailer account_activation password_reset

sending back

create  app/mailers/user_mailer.rb
create  app/mailers/application_mailer.rb
invoke  erb
create    app/views/user_mailer
create    app/views/layouts/mailer.text.erb
create    app/views/layouts/mailer.html.erb
invoke  test_unit
create    test/mailers/user_mailer_test.rb
create    test/mailers/previews/user_mailer_preview.rb

by a strange way app/views/layouts/mailer.html.erb file is not generated so when you call

layout 'mailer'

the rails core send you this error

"Missing template layouts/mailer"

you can resolve this by 2 ways.

First: comment out or delete layout 'mailer'.
Second: Creating the file.

Another ways like 'layout mailer' are bad practices cause this syntax have no sense for Rails.

If you create the file, use this code to fill it

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style>
      /* Email styles need to be inline */
    </style>
  </head>

  <body>
    <%= yield %>
  </body>
</html>

I had the same problem, and it seemed to work for me if I commented out the layout 'mailer' line in application_mailer

eg

class ApplicationMailer < ActionMailer::Base
  default from: '[email protected]'
  # layout 'mailer'
end

I had this same issue and what resolved it is ensuring I had two files in .../app/views/layouts/: mailer.html.erb and mailer.text.erb.

mailer.html.erb:

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style>
      /* Email styles need to be inline */
    </style>
  </head>

  <body>
    <%= yield %>
  </body>
</html>

mailer.text.erb:

<%= yield %>

If you don't already, you will need a folder within views called user_mailer and within that you will need a file for each of those methods (account_activation.html.erb & password_reset.html.erb). This is where the template of your email will be.