Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-13712

If a javax.mail.Session gets referred to using the "session" URL parameter, Apache Camel Mail ignored its hostnames.

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.22.1
    • 3.0.0.RC1, 3.0.0
    • camel-mail
    • None
    • Unknown

    Description

      A javax.mail.Session injected using JNDI can refer to one host per protocol. Referring to such a session using the URL query string parameter session=#jndiName seems to ignore the hosts the session is bound to:

      My first try was simply e.g. "smtp://?session=#jndiName". Now Apache Camel Mail complains about a missing hostname.

      So I tried "smtp://localhost?session=#jndiName" expecting that "localhost" would have been overridden using the SMTP host the session refers to, which is not the case. Camel complains that no SMTP server was listening on the host named "localhost".

      The workaround that works – but is somehow redundant in my opinion – is:

      @Resource(mappedName = "jndiName")
      {{ private Session mySession;}}

      ...to("smtp://"+mySession.getProperty("mail.smtp.host")+"?session=#jndiName")...

      The same also applies to the IMAP server (and likely to the other protocols supported by Java Mail as well).

      It would be nice iff referring to a JNDI injected session would take the session as-is to simplify the URL.

      I found an example for using the "session" parameter: "MailUsingCustomSessionTest". It would be helpful to have another example at hand that either takes the hostname from the session as my example above or that does not contain a hostname at all, given, Apache Camel Mail will support that in the future.

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            bachlipp Philipp Bachmann
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: