Embed images with Mailer API using custom HTML

69 views
Skip to first unread message

Nate Salisbury

unread,
Jul 17, 2013, 7:16:16 PM7/17/13
to madmi...@googlegroups.com
I'm going to be sending out promotions with custom HTML (generated in my rails app). I'm using the api defined here: https://madmimi.com/developer/mailer/methods under the "But wait... I want to use my own HTML" section. 

My problem is getting images embedded in the html properly.

I've tried embedding images in the html like this:

<img alt="My Image" border="0" height="80" src="data:image/gif;base64,R0lGODlhTgJQAMQAA...">

But that doesn't load properly in many email clients. I'd like to add the images as inline attachments like this:

----==_mimepart_51e7238b9494a_121f43fe894c6066c69780
Content-Type: image/gif;
 charset=UTF-8;
 filename=btn.gif
Content-Transfer-Encoding: base64
Content-Disposition: inline;
 filename=btn.gif
Content-ID: <51e7238b23ea3_121f...@nate.local.mail>

R0lGODlh3AAsAMQAAPitlvzWyvWDYf718vNvRvJkOfzg1/3q5faYe/m3o/WO
bvR5VPrBsPm3oveiiPvLvfeiifislfvWyv////FaLAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAACH/C1hNUCBEYXRhWE1QPD94cGFja2V0I...

----==_mimepart_51e7238b9494a_121f43fe894c6066c69780--

And then reference the image in the html with:

<img src=\"cid:51e7238b23ea3_121f...@nate.local.mail\" />

But I'm not sure how to do that through your api. Is it possible, and if so, how? Also, I'm using your gem (https://github.com/madmimi/madmimi-gem), rails 4 and ruby 2.

FYI, I'd prefer to keep my images in my app than somewhere like s3. 

Thanks for your help.


Nate
Reply all
Reply to author
Forward
0 new messages