[
https://issues.apache.org/jira/browse/GERONIMO-6884?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18035810#comment-18035810
]
Richard Zowalla edited comment on GERONIMO-6884 at 11/6/25 11:59 AM:
---------------------------------------------------------------------
According to the spec and the Javadoc of MimeBodyPart (Eclipse version, we
don't have JavaDoc here:
https://github.com/jakartaee/mail-api/blob/82f1e48a7c62b35ada125a56ebfec94195162b48/api/src/main/java/jakarta/mail/internet/MimeBodyPart.java#L178),
the constructor that takes an InputStream expects a fully valid MIME body
part. That means the stream must include headers, for example:
{code:java}
String mimePart = "Content-Type: application/octet-stream\r\n" +
"Content-Transfer-Encoding: base64\r\n\r\n" +
"Kg==";
MimeBodyPart attachmentPart = new MimeBodyPart(
new ByteArrayInputStream(mimePart.getBytes(StandardCharsets.US_ASCII))
);
{code}
Without proper headers, the parser won’t recognize the content correctly, as
far as I can tell or just use
{code:java}
public MimeBodyPart(final InternetHeaders headers, final byte[] content)
{code}
Guess this is done automatically, if data handlers are used.
was (Author: rzo1):
According to the spec and the Javadoc of MimeBodyPart (Eclipse version, we
don't have JavaDoc here:
https://github.com/jakartaee/mail-api/blob/82f1e48a7c62b35ada125a56ebfec94195162b48/api/src/main/java/jakarta/mail/internet/MimeBodyPart.java#L178),
the constructor that takes an InputStream expects a fully valid MIME body
part. That means the stream must include headers, for example:
{code:java}
String mimePart = "Content-Type: application/octet-stream\r\n" +
"Content-Transfer-Encoding: base64\r\n\r\n" +
"Kg==";
MimeBodyPart attachmentPart = new MimeBodyPart(
new ByteArrayInputStream(mimePart.getBytes(StandardCharsets.US_ASCII))
);
{code}
Without proper headers, the parser won’t recognize the content correctly, as
far as I can tell.
Guess this is done automatically, if data handlers are used.
> Jakarta mail behaves different from eclipse.angus
> -------------------------------------------------
>
> Key: GERONIMO-6884
> URL: https://issues.apache.org/jira/browse/GERONIMO-6884
> Project: Geronimo
> Issue Type: Bug
> Security Level: public(Regular issues)
> Affects Versions: Mail_2.1_1.0.1
> Environment: Apache Tomee 10.1.2 Plume
>
> Reporter: Jens Heitmann
> Priority: Major
> Attachments: example-mail.zip
>
>
> As mentioned in TOMEE-4547 Jakarta mail behaves differently from Javax and
> Angus implementation.
> I've attached a quick-and-dirty example project. (Adapt Config.java before
> testing in your environment). Try it in following modifications
> 1. use the mailtest as it is with Jakarta.mail inside WEB-INF/lib
> - Simple mail works directly or via commons mail
> - Multipart mail is send with empty body
> 2. remove Jakarta.mail from WEB-INF/lib
> - Sending any mail fails via 465
> 3. Replace Geronimo-mail in tomee/lib folder with angus-core, angus-mail and
> jakarta-mail
> - Everything works fine
> Mail is an essential part for web applications, sending invoices, password
> recovery etc. It would be nice if this is working out of the box in Geronimo
> too, to omit patching a tomee environment. It is dangerous in update
> situations, because it may be forgotten or it may have side effects.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)