2

I m developing web application using Ruby on Rails. I want to display an image in mail using net/smtp.. my code is...

msgstr = <<END_OF_MESSAGE
From: Your Name <your@mail.address>
To: Destination Address <someone@example.com>
MIME-Version: 1.0
Content-type: text/html
Subject: test message
Date: Sat, 23 Jun 2001 16:26:43 +0900
Message-Id: <unique.message.id.string@example.com>
<img src = "/my_proj/public/images/logo.jpeg" alt= "logo">
<b>  This is a test message.</b>
END_OF_MESSAGE

require 'net/smtp'
Net::SMTP.start('your.smtp.server', 25) do |smtp|
  smtp.send_message msgstr,
                    'your@mail.address',
                    'his_addess@example.com'
end

It is sending mail with all tags but not displaying th image while displaying alternate text. I hav put jpeg file every where n tested it.. but its not gettng the path of file and diplying the alternate text. Please anyone help me.. how to define path of file... or where to put this image file. I have changed

Content-type: text/html image/jpeg

but still its not working.

Sonal S.
  • 1,444
  • 1
  • 15
  • 31
  • Last paragraph of bjeanes's answer in the following `http://stackoverflow.com/questions/472450/how-do-i-create-email-with-css-and-images-from-rails` might be of your interest. You can also create a helper. Read on the post. – hitesh israni Nov 07 '12 at 06:46
  • Hmmm you're giving an relative path for your image, try with an absolute path (i.e. `http://myapp.com/my_proj/public/images/logo.jpeg`) – MrYoshiji Nov 07 '12 at 14:43
  • @MrYoshiji I did this... but still not working..;-( – Sonal S. Nov 09 '12 at 04:30

0 Answers0