Forum: Ruby on Rails Image Email Attachments Not Working

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
5c2806560a56cf727689b669ba948ba9?d=identicon&s=25 Adam J. (Guest)
on 2007-04-17 19:46
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 = "two2twelve@gmail.com"
     @from = "support@xmgimage.com"
  attachment :content_type => "image/jpg", :filename => "TestImage.jpg",
:body => File.read(RAILS_ROOT + "/public/images/TestImage.jpg")
end
72ee7b478a235f646c3495f03ebbe676?d=identicon&s=25 Andrew Stewart (Guest)
on 2007-04-18 13:35
(Received via mailing list)
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 Stewart

[1] http://api.rubyonrails.org/classes/ActionMailer/Base.html
This topic is locked and can not be replied to.