Hi Claus, Indeed, it's working very fine with a custom JavaMailSender setting. I was probably misled with the spring JavaMailSender configuration before.
FWIW, here's my configuration example in spring context: <beans> <camelContext xmlns="http://camel.apache.org/schema/spring"> <!-- SNIP --> <to uri="smtp://localhost?javaMailSender=#javaMailSender&from=ca...@example.com&to=ad...@example.com&subject=Notification" /> <!-- SNIP --> </camelContext> <bean id="jndiMailSession" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="java:comp/env/mail/Session" /> </bean> <bean id="javaMailSender" class="org.apache.camel.component.mail.DefaultJavaMailSender"> <property name="session" ref="jndiMailSession" /> <property name="protocol" value="smtp" /> </bean> Because DefaultJavaMailSender uses the protocol property to get a Transport from the mail Session, I needed to set the protocol property. It would help others if this kind of example is documented somewhere. ;-) Cheers, Woonsan -------------------------------------------- On Sat, 3/14/15, Claus Ibsen <claus.ib...@gmail.com> wrote: Subject: Re: SMTP with JNDI Mail Session To: "users@camel.apache.org" <users@camel.apache.org> Date: Saturday, March 14, 2015, 2:48 AM Hi The documentation is being fixed. Using a custom mail sender is tested from this unit test org.apache.camel.component.mail.MailCustomMailSenderTest On Sat, Mar 14, 2015 at 5:05 AM, Woonsan Ko <woon_...@yahoo.com.invalid> wrote: > After playing with mail component for smtp (camel-2.14.2), I think I found some problems. > > First, the documentation about 'javaMailSender' property [1] seems wrong and totally misleading. It should have referred to org.apache.camel.component.mail.JavaMailSender, not org.springframework.mail.javamail.JavaMailSender. > > The second problem is, there seems to be no way to set a reference to a JavaMailSender bean through URI parameters. It seems always to treat the parameter as String even when prefixed by '#' like the '#mySearchTerm' example in [1]. > > Shall I file JIRA issues for those? > > By the way, for some reason, I have to send e-mail via a server which host name contains an underscore. e.g, mail_server.example.com. If a host name contains an underscore, java.net.URI returns null on #getHost() call because it's wrong according to RFC 952 and RFC 1123. But in reality host names with underscore seem to have been allowed by servers and browsers. > Anyway, my workaround solution for now was to set 'host' parameter while placing something meaningless in the host part of the URI like the following example: > > <to uri="smtp://foo/?host=mail_server.example.com&username=TESTER&..." /> > > But, if they can already use it in mail applications or browsers, then why not allowing it as well in Camel? > > Regards, > > Woonsan > > [1] http://camel.apache.org/mail.html > > > -------------------------------------------- > On Fri, 3/13/15, Woonsan Ko <woon_...@yahoo.com.INVALID> wrote: > > Subject: Re: SMTP with JNDI Mail Session > To: "users@camel.apache.org" <users@camel.apache.org>, "Woonsan Ko" <woon_...@yahoo.com> > Date: Friday, March 13, 2015, 1:12 PM > > Oh, maybe I can specify > 'javaMailSender' parameter.FWIW, I've just found > an example configuring a javaMailSender bean using jndi: - > https://rozvoj.fit.cvut.cz/Main/spring-mail-a-jndi > > Thanks anyway, > Woonsan > > > From: Woonsan Ko <woon_...@yahoo.com.INVALID> > To: > "users@camel.apache.org" > <users@camel.apache.org> > > Sent: Friday, March 13, 2015 11:58 AM > Subject: SMTP with JNDI Mail Session > > Hi, > Can I use JNDI resource name in smtp: endpoint > instead of having to specify the detail in either the URL or > MailComponent bean [1]. It should be very useful if I can > simply refer to the configured JNDI mail session in the > container. > > Thanks in > advance, > Woonsan > > [1] http://camel.apache.org/mail.html > > > -- Claus Ibsen ----------------- Red Hat, Inc. Email: cib...@redhat.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen hawtio: http://hawt.io/ fabric8: http://fabric8.io/