ActionMailer with attachments, body is blank


#1

I am trying to use the Rails Recipe for sending emails with
attachments. However, when I add an attachment, my body fails to
render. The resulting email has the attachment, but is blank otherwise.

In the book, it mentions that this is “broken” in rails 1.0 and to
upgrade to a newer version or edge rails. Well, I am running on 1.1.2
and it’s still happening. When I look at my development.log file,
it’s saying that it doesn’t recognize “@mycontent” (the variable
holding the text of my mailer). However, if @ma is empty, it sees
@mycontent just fine. Suggestions?

Here is my mailer class:

class MarketingMailer < ActionMailer::Base

def standard_mailer
(_firstname,recipient,_subject,from_name,from_email,_content,_mailer_id,
_recipient_id,sent_at = Time.now)
@mailer = Mailer.find(_mailer_id)
@ma = @mailer.mailerattachments
@subject = _subject
@recipients = recipient
@from = from_name + " <" + from_email + “>”
@sent_on = sent_at
@headers[‘X-Mailer’] = ‘PFCSIntranet’
@headers[‘MIME-Version’] = ‘1.0’
@body = {:mycontent => _content, :firstname =>
_firstname, :recipient_id => _recipient_id, :mailer_id => _mailer_id }
@ma.each do |ma|
attachment :body => File.read("#{ma.attachment}"), :filename
=> ma.attachment[ma.attachment.rindex("/")+1…-1]
end
end
end


#2

I have the same issue. It appears that ActionMailer does not handle rich
messages with attachment.

Most likely a bug.