Camel
  1. Camel
  2. CAMEL-4093

pop3 component parameter deliverRawMailMessage

    Details

    • Type: New Feature New Feature
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.7.2
    • Fix Version/s: 2.8.0
    • Component/s: camel-mail
    • Labels:
      None
    • Environment:

      Solaris and Windows

    • Patch Info:
      Patch Available

      Description

      Old Subject: s/Mime signed Mails lead to Exceptions in pop3 component

      If a s/mime signed Mail is received by the pop3 Mail component a expection is thrown during handling the body of the message. This happens because a different type of body object is delivered by javamail.

      I fixed this issue by introducing a new parameter which makes it possible to deliver the complete mail source in the Camel message body. In this way you are able to handle the content with processors in a very flexiable way.

      ------------ additional remark -------------

      During my preparation of testcases I reduced the complexity of my former project, removed classpath jars just to the basics jars needed to run pop3 retieval. In this situation I don't get the error anymore (for Java DSL and Spring configuration).

      => The included patch is therefore just a new feature which is helpfull if a processor/consumer would like to get the complete mail source instead of just the payload. This can be controlled by a new pop3 component uri parameter

      deliverRawMailMessage

      example spring URL: pop3s://camel.test@pop.googlemail.com?password=pazzword&debugMode=true&deliverRawMailMessage=true

      I will deliver a unit test which tests the different behavior without disturbing the normal way of delivering mail content.

      1. CAMEL-4093-mapMailMessage.patch
        13 kB
        Richard Kettelerij
      2. CAMEL-4093_with_adapted_unit_test_regarding_MailMessageClass.diff
        23 kB
        Dr. Martin Menzel
      3. CAMEL-4093_with_unit_test.diff
        20 kB
        Dr. Martin Menzel
      4. CAMEL-4093.diff
        5 kB
        Dr. Martin Menzel

        Activity

        Hide
        Claus Ibsen added a comment -

        Thanks for reporting. Can you provide unit tests with your patch?

        Show
        Claus Ibsen added a comment - Thanks for reporting. Can you provide unit tests with your patch?
        Hide
        Dr. Martin Menzel added a comment -

        I try to create a unit test. If you plan to run the test in a CI environment, which mailserver shall I use to run the test against?

        Some of the actual tests use

        store.connect("localhost", 25, "jones", "secret");

        Is this ok for my tests too?

        Show
        Dr. Martin Menzel added a comment - I try to create a unit test. If you plan to run the test in a CI environment, which mailserver shall I use to run the test against? Some of the actual tests use store.connect("localhost", 25, "jones", "secret"); Is this ok for my tests too?
        Hide
        Claus Ibsen added a comment -

        Yeah if you look at the other unit tests, they use a Mocked Mail server. So just copy an existing unit test and modify it.

        Show
        Claus Ibsen added a comment - Yeah if you look at the other unit tests, they use a Mocked Mail server. So just copy an existing unit test and modify it.
        Hide
        Dr. Martin Menzel added a comment -

        The behavior of the pop3 component without using the patch is not treated as an error in the unit test. Without the patch the mailbody can be loaded in a MimeMessage object but all headers are missing so that signature checks of processors would fail. With the patch the complete message including mail headers is delivered as a mail body.

        Show
        Dr. Martin Menzel added a comment - The behavior of the pop3 component without using the patch is not treated as an error in the unit test. Without the patch the mailbody can be loaded in a MimeMessage object but all headers are missing so that signature checks of processors would fail. With the patch the complete message including mail headers is delivered as a mail body.
        Hide
        Claus Ibsen added a comment -

        Richard wait a bit on this one as we should take a bit care to not add to much stuff into our components. There is some pieces in this patch I would like to discuss/review a bit more.

        I suggest to postpone this for Camel 2.9.

        Show
        Claus Ibsen added a comment - Richard wait a bit on this one as we should take a bit care to not add to much stuff into our components. There is some pieces in this patch I would like to discuss/review a bit more. I suggest to postpone this for Camel 2.9.
        Hide
        Claus Ibsen added a comment -

        You should be able to do this already. There is a Camel MailMessage type which allows you to get access to the javax.mail.Message instance where you can get the raw message.

        I have just committed an unit test showing that
        http://svn.apache.org/viewvc?rev=1139760&view=rev

        Show
        Claus Ibsen added a comment - You should be able to do this already. There is a Camel MailMessage type which allows you to get access to the javax.mail.Message instance where you can get the raw message. I have just committed an unit test showing that http://svn.apache.org/viewvc?rev=1139760&view=rev
        Hide
        Claus Ibsen added a comment -

        We could maybe introduce a new mapMailMessage option (default true) that determines if Camel should map the raw mail message to headers/bodies etc.

        By disabling this option you will just receive the raw mail message which you can access as shown above in that commit.

        We have such an option in the JMS component.

        Show
        Claus Ibsen added a comment - We could maybe introduce a new mapMailMessage option (default true) that determines if Camel should map the raw mail message to headers/bodies etc. By disabling this option you will just receive the raw mail message which you can access as shown above in that commit. We have such an option in the JMS component.
        Hide
        Dr. Martin Menzel added a comment -

        When I understood Claus's comment right, the special MessageType can be used to deliver the mailapi Message Object.

        So to pipe this message over several steps we would have to write our own processor to transform the Message Object to a serialized Type (like String) before deliver this serialized Object to for example a file component.

        In the attached modified unit test you find a example where the Message is multicast to a mock and to a file component. Without an intermediate Processor the proposed type converter mechanism leads to a null pointer exception.

        Any comments to my thoughts are welcome.

        Show
        Dr. Martin Menzel added a comment - When I understood Claus's comment right, the special MessageType can be used to deliver the mailapi Message Object. So to pipe this message over several steps we would have to write our own processor to transform the Message Object to a serialized Type (like String) before deliver this serialized Object to for example a file component. In the attached modified unit test you find a example where the Message is multicast to a mock and to a file component. Without an intermediate Processor the proposed type converter mechanism leads to a null pointer exception. Any comments to my thoughts are welcome.
        Hide
        Richard Kettelerij added a comment -

        I've attached a patch containing the 'mapMailMessage' option that Claus suggested. I've used parts of Martin's patch.

        Show
        Richard Kettelerij added a comment - I've attached a patch containing the 'mapMailMessage' option that Claus suggested. I've used parts of Martin's patch.
        Hide
        Richard Kettelerij added a comment - - edited

        @Martin, with my patch your "testRawMessageByMailMessageClassConsumer" test should succeed if you do exchange.getBody(javax.mail.Message.class).

        Show
        Richard Kettelerij added a comment - - edited @Martin, with my patch your "testRawMessageByMailMessageClassConsumer" test should succeed if you do exchange.getBody(javax.mail.Message.class) .
        Hide
        Richard Kettelerij added a comment -

        Resolved (trunk: 1145884). Will update the website soon.

        Show
        Richard Kettelerij added a comment - Resolved (trunk: 1145884). Will update the website soon.
        Hide
        Richard Kettelerij added a comment -

        Updated docs + release notes.

        Show
        Richard Kettelerij added a comment - Updated docs + release notes.

          People

          • Assignee:
            Richard Kettelerij
            Reporter:
            Dr. Martin Menzel
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development