Forum: Ruby on Rails ActionMailer with attachments, body is blank

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Dylan M. (Guest)
on 2006-05-06 03:58
(Received via mailing list)
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]
Lon B. (Guest)
on 2006-07-12 00:44
I have the same issue. It appears that ActionMailer does not handle rich
messages with attachment.

Most likely a bug.
This topic is locked and can not be replied to.