[
https://issues.apache.org/jira/browse/EMAIL-6?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12475985
]
Ben Speakmon commented on EMAIL-6:
----------------------------------
I think the interface is clear; it accepts String or MimeMultipart content.
Since no subclass of Email is also a subclass of MimeMultipart, I don't know
how that could be made more explicit. Also, since a MimeMessage may consist of
zero or more MimeMultiparts, there's no obvious way to know what (if anything)
should be pulled out of it when trying to use addPart(). If there were an
existing addPart(MimeMessage), I could see your point. But JavaMail doesn't
guarantee that you can create a valid MimeMultipart from a given
MimePartDataSource (at least not without custom DataHandlers), so relying on
that seems dodgy as well.
Throwing an exception also assumes that there is some way to determine
precisely what a supplied MimeMultipart should be doing. What if the
MimeMultipart contains several different encoded binary images under a
multipart/related content type? Which one should be attached, and how should
that decision be made?
I think that once you get down to that level of detail, you should be using
JavaMail.
Dave, could you suggest some API comment that might make this clearer? I'd be
happy to do a patch for it. (Disclaimer: I am not a commons contributor and I
don't have checkin rights; I can only do a patch and then hopefully get Dion to
commit it. I don't have the ability to address it directly; I'm just a guy
who's used commons-email and decided to spend a lot of effort improving it.)
> [email] Errors when sending MultiPartEmail with another email as an attachment
> ------------------------------------------------------------------------------
>
> Key: EMAIL-6
> URL: https://issues.apache.org/jira/browse/EMAIL-6
> Project: Commons Email
> Issue Type: Bug
> Affects Versions: 1.0
> Environment: Operating System: other
> Platform: Other
> Reporter: Dave Cherkassky
> Attachments: MultiPartEmailTest.java.patch
>
>
> Take a look at the code below:
> if( debugMode ) {
> if( logger.isInfoEnabled() ) {
> logger.info( "DEBUG mode is on. Sending email to " + debugEmailAddress );
> }
> MultiPartEmail debugEmail = new MultiPartEmail();
> if( logger.isDebugEnabled() ) {
> debugEmail.setDebug( true );
> }
> debugEmail.setBounceAddress( debugEmailAddress );
> debugEmail.setFrom( debugEmailAddress );
> debugEmail.addReplyTo( debugEmailAddress );
> debugEmail.addTo( debugEmailAddress );
> debugEmail.setSubject( "Test Message: " + email.getSubject() );
> debugEmail.setMsg( "The email manager is operating in test mode. " +
> "Attached is a message it would have sent had it been running for real."
> );
> debugEmail.addPart( new MimeMultipart(
> new MimePartDataSource( email.getMimeMessage() ) ) );
> debugEmail.setMailSession( emailSession );
> messageId = debugEmail.send();
> }
> I get the following exception when I call debugEmail.send():
> 2006-03-12 09:07:01,140 [ main] INFO
> com.djinnsoft.jade.email.EmailManager: DEBUG mode is on. Sending email to
> [EMAIL PROTECTED]
> 2006-03-12 09:07:01,640 [ main] WARN
> com.djinnsoft.jade.email.EmailManager: Error emailing sent item 2000035:
> Sending
> the email to the following server failed : null:25
> javax.mail.SendFailedException: Sending failed;
> nested exception is:
> javax.mail.MessagingException: IOException while sending message;
> nested exception is:
> java.io.IOException: "text/plain" DataContentHandler requires String object,
> was given object of type class javax.mail.internet.MimeMultipart
> at javax.mail.Transport.send0(Transport.java:219)
> at javax.mail.Transport.send(Transport.java:81)
> at org.apache.commons.mail.Email.sendMimeMessage(Email.java:863)
> at org.apache.commons.mail.Email.send(Email.java:898)
> at
> com.djinnsoft.jade.email.EmailManager.processMailing(EmailManager.java:1205)
> (line 1205 corresponds to "messageId = debugEmail.send();" in my code)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]