| ||||
A blog about Ruby, Rails and other Tech. Mostly.Back to blog
The problem is to do a message that has plain and html alternatives. And the html version has inline images. This is how I have seen it done: X-Mailer: PHPMailer [version 1.72] MIME-Version: 1.0 Content-Type: multipart/related; type="text/html"; boundary="b1_691596577150e2e5332d9397dd691d6c" --b1_691596577150e2e5332d9397dd691d6c Content-Type: multipart/alternative; boundary="b2_691596577150e2e5332d9397dd691d6c" --b2_691596577150e2e5332d9397dd691d6c Content-Type: text/plain; charset = "iso-8859-1" Content-Transfer-Encoding: 8bit Your email client/program appears to be unable to display HTML content. Below you can find a simplified version of the original message; all content is there, but without a proper layout. If you have any questions, please don't hesitate to contact us. ~~~~~~ blah blah blah message --b2_691596577150e2e5332d9397dd691d6c Content-Type: text/html; charset = "iso-8859-1" Content-Transfer-Encoding: 8bit <div style="color:#004080; font: 11px Verdana, Arial, sans-serif; width: 600px;"> <p>blah blah message</p> <img src=="cid:logo"> </div> --b2_691596577150e2e5332d9397dd691d6c-- --b1_691596577150e2e5332d9397dd691d6c Content-Type: image/gif; name="logo.gif" Content-Transfer-Encoding: base64 Content-ID: <logo> Content-Disposition: inline; filename="logo.gif" R0lGODlhWwEwANUAAMyfnPnz859LRbNva+XPzezb2qxjXtm3tPLn5r+HhNKrqKZXUv/787l7d/nK Rd/DwfzinMaTkP3xzfvUa/rNUvrRXvvYd/vbhP702v745v3twfzfkPzmqP3qtJk/OfnGOf///wAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAAAAAAALAAAAABbATAAAAb/QJBw ... --b1_691596577150e2e5332d9397dd691d6c-- That is, the overall type is multipart/related with a type=text/html. Then comes a boundary, and content-type multipart/alternative with a different (second) boundary specified. Then comes the second boundary and the text/plain section. Followed by the second boundary and the text/html section. Finally comes the second boundary and then the first boundary and lastly the image followed by the first boundary to finish. It wasn't clear to me from the specs how to do this until now. Back to blog |