|
It seems to me that what you have done could be the basis of commons-email 1.1. I have never
thought that the package structure, scope of methods, etc was very well thought out. I'd be happy to take your patches if you wanted to rework them to be improvements on the existing code versus standalone code. And if we can beef up the testing. For my part, I am not an email guru, I was just shepherding commons-email to get it to 1.0, so I can't I think we should look at:
a) Fix HtmlEmail rather than introducing a HtmlEmail2 b) Make HtmlEmail easier to subclass. Created an attachment (id=17748)
Patch to HtmlEmail This is HtmlEmail2 produced as a patch versus HtmlEmail Attaching a cleaned-up and debugged version of the original HtmlEmail patch with new embed() tests. Confirmed to work properly on Thunderbird, Gmail, and Mac Mail.
The original patch also fixed Ben's patch works well. Applied.
I don't think the current multi-part structure is strictly according to the MIME recommendations.
The currently proposed layout of a multi-part message containing a text/plain part, as well as a text/html part with embedded images is... Entity Content-Type Encoding ... but since the embedded images are part of the text/html part, and thus should not be available to a text/plain reader, I believe the proper layout of such a message should be: Entity Content-Type Encoding ... with possible attachments appearing as (2, 3, ...). Furthermore, I believe that if a HtmlEmail is composed with only a text/plain component, it should result in a message identical to a MultiPartEmail message, rather than synthetically generating a text/html message with the plaintext contained in a <pre>...</pre> block, which bloats the smtp message to twice the size, for no reason. Should this be raised as two separate (new) JIRA reports against EMAIL version 1.1? |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
HtmlEmail2.java
Some notes about my contributed code:
I chose not to patch HtmlEmail so that my implementation can co-exist with the
original HtmlEmail class; my class is named HtmlEmail2. Secondly I subclassed
MultiPartEmail not HtmlEmail since some methods in HtmlEmail were private and
in the end my work touched pretty much everything in HtmlEmail.
I also raised an issue (COM-2497) with HtmlEmail that if a caller embededs the
same image several times into an email then it is encoded several times into
the payload of the email. A typical usage scenario for Html emails is that one
uses common 'spacer' images. Of course the caller could resolve this for
themselves, but as a convenience I chose to implement embed() in a way that
identifies common images (using the 'name' parameter) adding them only once
into the email. This fix is included in my HtmlEmail2 class.
Certain useful methods in the org.apache.commons.mail package have package
access restrictions. My code is pacakged in this package so there is no issue,
but users of my code will not be able to remove my code into their own package
and may get sealing violation issues if they attempt to use it in a separate
jar from the binary distribution of commons-email.jar. A simple solution is to
obtain the source for commons-email and compile your own jar from source,
co-locating my src code with the rest of the formal distribution of the
package.