You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Claus Ibsen <cl...@gmail.com> on 2013/02/03 13:34:43 UTC

Re: camel-mail component is "asymmetric" !

Hi

Yeah you can extend MailBinding and set a custom instance on the mail endpoint.
We should possible extract that as an interface, to make it easier to
do custom bindings.
And as well allow to configure the binding on the component level, so
you can set it once, and apply for all mail endpoints in-use.


Mind that com.sun.mail.imap.IMAPNestedMessage is a SUN specific class
and not part of the Java Mail API per see.
So we cannot use that in camel-mail, as it should be mail provider agnostic.

End users is of course welcome to create their custom binding classes
and do their own mail binding.
You can also turn mapMailMessage=false, and do your own mapping.



On Mon, Jan 28, 2013 at 3:35 PM, OrackBahama <jd...@metadok.de> wrote:
> Hi,
>
> when I send a mail message with attachments using the camel-mail component,
> the mail message is composed as "multipart mail message" and all of my
> camel-message headers are appended to the mail and being sent.
>
> But when I poll a mailbox full of those messages there is a gap (asymmetry):
> The camel-mail component does not read and reconstruct all custom headers
> into my camel message as expected.
>
> I looked at the source code of the mail-component (Camel 2.10.3) and think I
> have found an inconsistency in the method
>
> protected Map<String, Object> extractHeadersFromMail(Message mailMessage,
> Exchange exchange)
>
> of the MailBinding.java class.
> The current version only calls  mailMessage.getAllHeaders() and does *not*
> consider that this could be a multipart content or a nested message. I think
> there's lack of some more iterators over BodyParts "part.getAllHeaders()"
> and/or IMAPNestedMessages "nestedMessage.getAllHeaders()" to really retrieve
> *all* possible custom headers - and finally be symmetric to the mail
> creation logic.
>
> ...
> Object content = mailMessage.getContent();
> if ( content  instanceof Multipart )
> {
>   // Iterate over BodyParts and get all headers per part
>   ...
> }
> else if (content  instanceof IMAPNestedMessage)
> {
>   // Recursively walk through IMAPNestedMessage, find Multiparts and iterate
> over BodyParts and get all headers per part
> ...
> }
>
> Can somebody verify or confirm that ?
> Is it possible to extend that class and override this function of that
> component somehow - or do I have to write a custom mail-component ? Maybe
> this will be fixed in a future version of camel ? ...
>
> Best regards
>
>
>
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/camel-mail-component-is-asymmetric-tp5726418.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen