# ActionMailer with attachments, body is blank

**URL:** <https://www.ruby-forum.com/t/actionmailer-with-attachments-body-is-blank/225906>\
**Category:** Rails\
**Created:** [May 6, 2006, 1:58am UTC](https://www.ruby-forum.com/t/actionmailer-with-attachments-body-is-blank/225906 "2006-05-06T01:58:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dmarkow](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bc8723/32.png) [@dmarkow](https://www.ruby-forum.com/u/dmarkow)\
**Post date:** [May 6, 2006, 1:58am UTC](https://www.ruby-forum.com/t/actionmailer-with-attachments-body-is-blank/225906/1 "2006-05-06T01:58:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dmarkow](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bc8723/32.png) [@dmarkow](https://www.ruby-forum.com/u/dmarkow)\
**Post date:** [July 11, 2006, 10:44pm UTC](https://www.ruby-forum.com/t/actionmailer-with-attachments-body-is-blank/225906/2 "2006-07-11T22:44:12Z")

</div>

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

Most likely a bug.
