Weird issue with actionmailer on rails 4.2.4

17 views
Skip to first unread message

Patrick Paul-Hus

unread,
Sep 7, 2015, 6:42:37 PM9/7/15
to Ruby on Rails: Talk
Hi, I have a pretty standard and simple mailer model with its own html and text view. When I send it, the content of the email is actually sorta headers and the actual message isn’t there.

The mailer looks like this:

class TestMailer < ApplicationMailer
  default from: "nor...@foobar.com"

  def test_message
    to = "dan...@foobar.com"
    subject = "Message"
    @message = "This is the message"
    mail to: to, reply_to: "f...@bar.com", subject: subject, template_path: 'test_mailer', template_name: 'test_message'
  end
end

The views just print the @message variable. but what I receive looks like this:

irb(main):003:0> mailer.html_part.body.to_s
=> "<html>\n  <body>\n    Date: Mon, 07 Sep 2015 18:34:23 -0400\nFrom: nor...@foobar.com\nReply-To: dan...@foobar.com\nTo: dan...@foobar.com\nMessage-ID: &lt;55ee10ef12ed1_bc5...@pph.local.mail&gt;\nSubject: Message\nMime-Version: 1.0\nContent-Type: text/plain\nContent-Transfer-Encoding: 7bit\n\n\n\n  </body>\n</html>\n"
irb(main):004:0>

Anyone has any idea what the heck is going on?

Patrick Paul-Hus

unread,
Sep 7, 2015, 8:52:32 PM9/7/15
to Ruby on Rails: Talk
Nevermind... I was using the <%= message %> variable instead of <%= @message %> O_o


On Monday, September 7, 2015 at 6:42:37 PM UTC-4, Patrick Paul-Hus wrote:
Hi, I have a pretty standard and simple mailer model with its own html and text view. When I send it, the content of the email is actually sorta headers and the actual message isn’t there.

The mailer looks like this:

class TestMailer < ApplicationMailer
  default from: "nor...@foobar.com"

  def test_message
    to = "dan...@foobar.com"
    subject = "Message"
    @message = "This is the message"
    mail to: to, reply_to: "f...@bar.com", subject: subject, template_path: 'test_mailer', template_name: 'test_message'
  end
end

The views just print the @message variable. but what I receive looks like this:

irb(main):003:0> mailer.html_part.body.to_s
=> "<html>\n  <body>\n    Date: Mon, 07 Sep 2015 18:34:23 -0400\nFrom: nor...@foobar.com\nReply-To: dan...@foobar.com\nTo: dan...@foobar.com\nMessage-ID: &lt;55ee10ef12ed1_bc5a3fc1d586020066562@pph.local.mail&gt;\nSubject: Message\nMime-Version: 1.0\nContent-Type: text/plain\nContent-Transfer-Encoding: 7bit\n\n\n\n  </body>\n</html>\n"
irb(main):004:0>
Reply all
Reply to author
Forward
0 new messages