Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

image_tag encoded in base64 in rails

Is there any way to make image_tag in rails 3.1 convert the image into base64 format to send it in the email.

If there is no way to do this can anyone tell me the way to send emails containing images which are stored server side? If i just use image_tag for rendering images they are not displayed in the email.

like image 609
roman Avatar asked Oct 28 '25 14:10

roman


1 Answers

To send images with emails use attachment property on mail to sent the file with mail:

attachments['logo.png'] = File.read(Rails.public_path + '/images/logo.png')

This file will be sent with mail in attachments. To use this image on email body use attachments.inline[] and then in template image_tag attachments[].url.

Also note that Rails 3 have issue with inline attachments, as they present, all ordinary attachments will not be visible in major email clients, as Thunderbird or Outlook.

like image 86
Mark Huk Avatar answered Oct 31 '25 05:10

Mark Huk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!