ActionMailer sends emails with an empty body

It seems that while I was updating rails to 3.2.8, the body is not set when I create and send emails. At this time, the code around the mail programs did not change, with the exception of ActionMailer, which also upgraded to 3.2.8.

I have beta_request_mailer.rbin app/mailersthe following method:

def beta_request(request)
  mail(
    :to => "#{request[:name]} <#{request[:email]}>",
    :subject => 'Thanks for requesting an invite to xxxxx!'
  )
end

I also have a body file that worked fine: app/views/beta_request_mailer/beta_request_email.html.erb

The letter is sent perfectly, without any body. By launching the console, the mail object created in beta_request does not have a body at startup mail.body. If I set up the body manually, it will be sent.

What has changed, what do I not know about?

+5
source share
3 answers

_email

+1

, , , .deliver! .deliver ( )

+2

My decision was very interesting.

  • First, the Rails 4 application throws an error without a layout file for the mailer.

  • I created an empty layout file mailer.html.slim. This led to the delivery of messages without content.

  • The solution was to add ==yieldinsidemailer.html.slim

It works like a charm. Hope this was your problem and it helped you.

+1
source

All Articles