Hi, I'm trying to use ActionMailer to send an image as an attachment to an email. Here's my code:
class ContactMailer < ActionMailer::Base def message(sent_at = Time.now) from 'b...@example.com' recipients 'j...@example.com' subject 'New message' sent_on sent_at body {} attachment :content_type => "image/jpeg", :body => File.read("public/images/rails.png") end end This works, in so far as the email is delivered okay (obviously with different addresses), but the image attached to the email seems to be corrupted. It doesn't display in my mail client and when I download it and try to open it with a suitable program I get the message that the file is either too large or corrupted. I tried replacing the image with a pdf as follows: attachment :content_type => "application/pdf", :body => File.read("public/images/test.pdf") and this works fine. Can anybody give me a clue as to what I'm doing wrong? Thanks in advance. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.