I just discovered that my code for embedding images that I had working on coldfusion 9, doesn't work on Railo. First time I've tested it in almost 3 years.
When I compare the email headers with the output of phpmailer, I find it isn't possible to mimic the output phpmailer generates using railo cfmail. I don't know what coldfusion output is and whether it works in coldfusion or not, but it would be nice if this worked in railo.
If someone has code for this that works in the Thunderbird email client let me know. Many other clients will accept the cfmail headers for cid embedded images, but Thunderbird expects a more strict RFC compliance that I don't know how to generate with CFMAIL. I can generate the correct syntax with phpmailer though.
I've actually tried a lot of variations of the code, but I think the most correct methods are listed below.
The correct raw email header output that thunderbird understand is supposed to be this:
...removed other headers for brevity...
Content-Type: multipart/related;
boundary="b1_39a4ced68062ba31f7d21e28eb7f8e72"
--b1_39a4ced68062ba31f7d21e28eb7f8e72
Content-Type: text/html; charset=us-ascii
Hello, <b>my friend</b> <img src="cid:logo" width="20" height="20">!
--b1_39a4ced68062ba31f7d21e28eb7f8e72
Content-Type: image/jpeg; name="slide1.jpg"
Content-Transfer-Encoding: base64
Content-ID: <logo>
Content-Disposition: inline; filename=slide1.jpg
/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP/sABFEdWNreQABAAQAAABQ
lots more base64....
But Railo generates an email like this that is blank when opened in thunderbird:
Content-Type: multipart/related
X-Mailer: Railo Mail
X-SG-EID: UzvFFkX/YNBKOFeeClTgeL+UnUBTPNXMDPzrdkNsUDz5KVf+Bes3R3yf4OH16LwVSrhm4sp5GHTsqZAn0CUm7+7DiieWOKWREqQMwJmCJTErl/7PIun3iTcUhb6dXsAn2OQ6cdj48LQx4/pGB4I4lm8A1nvzU/R1baYMpi37yGs=
Sender: emailremoved
This is a multi-part message in MIME format...
----
with this code:
<cfmail to="emailremoved" from="emailremoved" subject="email with image" charset="utf-8" type="html">
<cfmailparam name="Content-Type" value="multipart/related">
<cfmailparam file="slide1.jpg" contentid="<logo>" disposition="inline" />
<cfmailpart type="text/html"> Hello, <b>my friend</b> <img src="cid:logo" width="20" height="20">!
</cfmailpart>
</cfmail>
and the same with this code:
<cfmail to="someone" from="someone" subject="email with image" charset="utf-8" type="html">
<cfmailparam name="Content-Type" value="multipart/related">
Hello, <b>my friend</b> <img src="cid:logo" width="20" height="20">!
<cfmailparam file="slide1.jpg" contentid="<logo>" disposition="inline" />
</cfmail>
With this code I get an email with the image as an attachment instead of being inline in the html.:
<cfmail to="emailremoved" from="emailremoved" subject="email with image" charset="utf-8" type="html">
<cfmailparam file="slide1.jpg" contentid="<logo>" disposition="inline" />
<cfmailpart type="text/html"> Hello, <b>my friend</b> <img src="cid:logo" width="20" height="20">!
</cfmailpart>
</cfmail>
This was supposed to be fixed according to
https://issues.jboss.org/browse/RAILO-661 but I don't see that it is and I'm trying to use the same code example in that bug report pretty much. I'm concerned that a regression has happened or that the fix is still wrong.
The main difference between phpmailer and the cfmail output is the first "Content-Type". phpmailer has this header:
Content-Type: multipart/related;
boundary="b1_39a4ced68062ba31f7d21e28eb7f8e72"
but that isn't possible to do with cfmail (Based on my limited knowledge).
I think the multipart/related mime concept is that it tells the mail client that the inline images and the html are "related", so it combines them, instead of displaying them separately.
Any chance we could get a fix that could allow the more strict output that works in thunderbird?