# Image Email Attachments Not Working

**URL:** <https://www.ruby-forum.com/t/image-email-attachments-not-working/92278>\
**Category:** Rails\
**Created:** [April 17, 2007, 7:46pm UTC](https://www.ruby-forum.com/t/image-email-attachments-not-working/92278 "2007-04-17T19:46:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sideshow](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3e96dc/32.png) [@sideshow](https://www.ruby-forum.com/u/sideshow)\
**Post date:** [April 17, 2007, 7:46pm UTC](https://www.ruby-forum.com/t/image-email-attachments-not-working/92278/1 "2007-04-17T19:46:52Z")

</div>

Hey all,

I’m been struggling with an email attachment problem for a few weeks  
now. I can’t seem to get image attachments in an email to work. I’d  
receive the email fine, but the actual image in the attachment is broken  
(the actual image data never gets sent).

I’ve tried a dozen different code snippets, none of which work with  
images. I can however, send any other type of file and receive it  
perfectly (such as txt files, etc…)

Any ideas what it could be?

A bit of my code:

## Controller

def send\_email  
ClientNotify.deliver\_images\_with\_attachments  
end

## Mailer model

def images\_with\_attachments()  
@subject = "test Subject  
@body = {:body =\> “this is testing text”}  
@recipients = “removed\_email\_address@domain.invalid”  
@from = “removed\_email\_address@domain.invalid”  
attachment :content\_type =\> “image/jpg”, :filename =\> “TestImage.jpg”,  
:body =\> File.read(RAILS\_ROOT + “/public/images/TestImage.jpg”)  
end

---

<div class="post-metadata">

**Author:** ![sideshow](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3e96dc/32.png) [@sideshow](https://www.ruby-forum.com/u/sideshow)\
**Post date:** [April 18, 2007, 1:35pm UTC](https://www.ruby-forum.com/t/image-email-attachments-not-working/92278/2 "2007-04-18T13:35:37Z")

</div>

On 17 Apr 2007, at 18:46, Adam J. wrote:

> I’m been struggling with an email attachment problem for a few weeks  
> now. I can’t seem to get image attachments in an email to work. I’d  
> receive the email fine, but the actual image in the attachment is  
> broken  
> (the actual image data never gets sent).  
> [snip]  
> end  
> According to the documentation[1], the :content\_type should be “image/  
> jpeg” not “image/jpg”. Perhaps that’s the problem?

And is the :filename necessary?

Regards,  
Andy S.

[1] [http://api.rubyonrails.org/classes/ActionMailer/Base.html](http://api.rubyonrails.org/classes/ActionMailer/Base.html)
