You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Stephan Siano (JIRA)" <ji...@apache.org> on 2016/07/29 05:21:20 UTC

[jira] [Created] (CAMEL-10200) Mail consumer sets wrong Content-Type header for mails with attachment

Stephan Siano created CAMEL-10200:
-------------------------------------

             Summary: Mail consumer sets wrong Content-Type header for mails with attachment
                 Key: CAMEL-10200
                 URL: https://issues.apache.org/jira/browse/CAMEL-10200
             Project: Camel
          Issue Type: Bug
          Components: camel-mail
    Affects Versions: 2.17.2, 2.16.3
            Reporter: Stephan Siano
            Priority: Minor


If a mail with attachment is received the mail consumer components (imap and pop3) set the message body to a Multipart Message and take over all headers from the mail message.

All known consumers of the message body (including the mail (SMTP) producer) will convert the body into somthing else (using one of the provided type converters) and will receive the first text part of the messsage, which is the mail body. This is the behaviour one would expect.

Unfortunately the Content-Type header taken over from the Multipart mail will contain a multipart content type (including the MIME boundary) of the whole mail, not the content type of the entity usually used as mail body,

As a consequence the following route will always fail:
{code}
from("pop3://james3@localhost?consumer.delay=1000").removeHeader("to").to("smtp://james4@localhost");
{code}

The error message is.
{noformat}
2016-07-28 20:01:24,892 [ames2@localhost] ERROR DefaultErrorHandler            - Failed delivery for (MessageId: ID-WDFD30052822A-54830-1469728883014-0-1 on ExchangeId: ID-WDFD30052822A-54830-1469728883014-0-2). Exhausted after delivery attempt: 1 caught: javax.mail.MessagingException: Missing start boundary

Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId              ProcessorId          Processor                                                                        Elapsed (ms)
[route1            ] [route1            ] [pop3://james2@localhost?consumer.delay=1000                                   ] [        18]
[route1            ] [to1               ] [smtp://james3@localhost                                                       ] [        13]

Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
javax.mail.MessagingException: Missing start boundary
	at javax.mail.internet.MimeMultipart.parse(MimeMultipart.java:682)
	at javax.mail.internet.MimeMultipart.updateHeaders(MimeMultipart.java:513)
	at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1483)
	at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1131)
	at javax.mail.internet.MimeMultipart.updateHeaders(MimeMultipart.java:515)
	at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1483)
	at javax.mail.internet.MimeMessage.updateHeaders(MimeMessage.java:2198)
	at javax.mail.internet.MimeMessage.saveChanges(MimeMessage.java:2159)
	at org.apache.camel.component.mail.DefaultJavaMailSender.send(DefaultJavaMailSender.java:118)
	at org.apache.camel.component.mail.MailProducer.process(MailProducer.java:63)
	at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
	at org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:173)
	at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:362)
	at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:168)
	at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:525)
	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)
	at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:91)
	at org.apache.camel.component.mail.MailConsumer.processExchange(MailConsumer.java:382)
	at org.apache.camel.component.mail.MailConsumer.processBatch(MailConsumer.java:221)
	at org.apache.camel.component.mail.MailConsumer.poll(MailConsumer.java:128)
	at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:175)
	at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:102)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
{noformat}

The provided patch will set the Content-Type header of the message to the content type of the first text part of the multipart (the one which is also returned by the type converters)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)