ActionMailer with attachments, body is blank

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
_recipient_id,sent_at =
@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 =>"#{ma.attachment}"), :filename
=> ma.attachment[ma.attachment.rindex("/")+1…-1]

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

Most likely a bug.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs