You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by tn...@apache.org on 2014/10/02 22:07:03 UTC
svn commit: r1629061 - in /commons/proper/email/trunk/src:
changes/changes.xml main/java/org/apache/commons/mail/HtmlEmail.java
Author: tn
Date: Thu Oct 2 20:07:03 2014
New Revision: 1629061
URL: http://svn.apache.org/r1629061
Log:
[EMAIL-142] HtmlEmail with both an html and plain text content but no attachments or embedded images will now be created with mimetype multipart/alternative instead of multipart/mixed. Thanks to Marcin Tomiak.
Modified:
commons/proper/email/trunk/src/changes/changes.xml
commons/proper/email/trunk/src/main/java/org/apache/commons/mail/HtmlEmail.java
Modified: commons/proper/email/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/changes/changes.xml?rev=1629061&r1=1629060&r2=1629061&view=diff
==============================================================================
--- commons/proper/email/trunk/src/changes/changes.xml (original)
+++ commons/proper/email/trunk/src/changes/changes.xml Thu Oct 2 20:07:03 2014
@@ -23,6 +23,10 @@
<body>
<release version="1.3.4" date="TBD">
+ <action dev="tn" type="fix" issue="EMAIL-142" date="2014-10-02" due-to="Marcin Tomiak">
+ An "HtmlEmail" with both, an html and plain text content but no attachments or embedded
+ images will now be created with mimetype "multipart/alternative" instead of "multipart/mixed".
+ </action>
<action dev="tn" type="add" issue="EMAIL-141" date="2014-09-14" due-to="Stephen Kruger">
Added support for mapping of content-ids to DataSource in "MimeMessageParser".
</action>
Modified: commons/proper/email/trunk/src/main/java/org/apache/commons/mail/HtmlEmail.java
URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/main/java/org/apache/commons/mail/HtmlEmail.java?rev=1629061&r1=1629060&r2=1629061&view=diff
==============================================================================
--- commons/proper/email/trunk/src/main/java/org/apache/commons/mail/HtmlEmail.java (original)
+++ commons/proper/email/trunk/src/main/java/org/apache/commons/mail/HtmlEmail.java Thu Oct 2 20:07:03 2014
@@ -548,7 +548,7 @@ public class HtmlEmail extends MultiPart
bodyContainer = bodyEmbedsContainer;
this.addPart(bodyEmbedsContainer, 0);
- //If TEXT body was specified, create a alternative container and add it to the embeds container
+ // If TEXT body was specified, create a alternative container and add it to the embeds container
if (EmailUtils.isNotEmpty(this.text))
{
bodyContainer = new MimeMultipart("alternative");
@@ -566,9 +566,23 @@ public class HtmlEmail extends MultiPart
}
else if (EmailUtils.isNotEmpty(this.text) && EmailUtils.isNotEmpty(this.html))
{
- //If both HTML and TEXT bodies are provided, create a alternative container and add it to the root container
- bodyContainer = new MimeMultipart("alternative");
- this.addPart(bodyContainer, 0);
+ // EMAIL-142: if we have both an HTML and TEXT body, but no attachments or
+ // inline images, the root container should have mimetype
+ // "multipart/alternative".
+ // reference: http://tools.ietf.org/html/rfc2046#section-5.1.4
+ if (this.inlineEmbeds.size() > 0 || isBoolHasAttachments())
+ {
+ // If both HTML and TEXT bodies are provided, create an alternative
+ // container and add it to the root container
+ bodyContainer = new MimeMultipart("alternative");
+ this.addPart(bodyContainer, 0);
+ }
+ else
+ {
+ // no attachments or embedded images present, change the mimetype
+ // of the root container (= body container)
+ rootContainer.setSubType("alternative");
+ }
}
if (EmailUtils.isNotEmpty(this.html))