Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActionMailer sending emails with empty body

It appears that around the time that I upgraded rails to 3.2.8, the body isn't being set when I create and send emails. No code around the mailers has changed in this time, with the exception of ActionMailer also upgrading to 3.2.8.

I have beta_request_mailer.rb in app/mailers with the 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 which worked fine: app/views/beta_request_mailer/beta_request_email.html.erb

The email is being sent fine, just without any body. Running in the console, the mail object that's created in beta_request has no body when running mail.body. If I set a body manually, that gets sent out.

What's changed that I'm not aware of?

like image 711
w2bro Avatar asked Oct 07 '22 20:10

w2bro


2 Answers

I was also getting emails that arrived ok and with the correct subject, but with no content in the mail and found that using the .deliver! instead of just .deliver method cured the problem (though don't know why)

like image 151
Mitch Avatar answered Oct 13 '22 12:10

Mitch


Fixed by removing _email from file name

like image 24
w2bro Avatar answered Oct 13 '22 11:10

w2bro