Sven
2009-Jul-30 23:28 UTC
Problem with implicit multipart emails using ActionMailer in Rails 2.3.3
With earlier versions of Rails ActionMailer used to implicitly send
multipart (text/plain and text/html) email messages for me, but it
looks like now it''s sending two text/plain parts.
Simplified details:
Here''s my model:
class Notifications < ActionMailer::Base
def confirmation(sent_at = Time.now)
@subject = ''Thank you for registering''
@body = {}
@recipients =
''test.recipient-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org''
@from =
''test.sender-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org''
@sent_on = sent_at
@headers = {}
end
end
I have two views called confirmation.text.plain.erb and
confirmation.text.html.erb
In a unit test, for debug purposes, I have:
sent = Notifications.create_confirmation
puts sent.to_s
The resulting message looks like this:
--------------------------------------------------------------------
Date: Thu, 30 Jul 2009 17:45:04 -0400
From: test.sender-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org>
To: test.recipient-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org
Subject: Thank you for registering
Mime-Version: 1.0
Content-Type: multipart/alternative;
boundary=mimepart_4a72146057a58_11b414263a41e
--mimepart_4a72146057a58_11b414263a41e
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-2022-jp
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Message text from confirmation.text.plain.erb
--mimepart_4a72146057a58_11b414263a41e
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-2022-jp
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Message text from confirmation.text.html.erb
--mimepart_4a72146057a58_11b414263a41e--
--------------------------------------------------------------------
The second message part should have a content-type of text/html, but
it doesn''t (any more; this worked in the past).
This happens regardless of whether I run test\unit
\notifications_test.rb directly or whether I run it via rake
test:units.
Searching for more information led me to a similar problem with Rails
2.3.2 and I tried the fix suggested at
https://rails.lighthouseapp.com/projects/8994/tickets/2263-rails-232-breaks-implicit-multipart-actionmailer-tests#ticket-2263-23
but it isn''t helping.
Does anyone know why the implicit multipart functionality isn''t
working for me?
Thanks,
Sven
