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 ‘[email protected]’
recipients ‘[email protected]’
subject ‘New message’
attachment :content_type => “image/jpeg”, :body =>
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
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 =>
and this works fine.
Can anybody give me a clue as to what I’m doing wrong?
Thanks in advance.