Thank you James,

I succeed to send email, using this URI:

smtp://[EMAIL PROTECTED]

I've seen that you can use of # to define a destination email by look at
code source (otherwise it seems that the email [EMAIL PROTECTED] is used.


Now I try to use my own MailComponent instance with the scheme "mail"; here
the code:


JndiContext context = new JndiContext();
                
MailComponent mail = new MailComponent();
context.bind("mail", mail);
                
CamelContext camelContext = new DefaultCamelContext(context);                   
                
camelContext.addRoutes(new RouteBuilder() {

  public void configure() {
    from("timer:myTimerEvent?fixedRate=true&delay=0&period=1000")
    .setBody(Builder.constant("Salut
!")).to("mail://[EMAIL PROTECTED]@www.com");                    
  }
                    
});

When running the Camel context I get the following exception that makes me
crasy:

GRAVE: On delivery attempt: 0 caught:
org.springframework.mail.MailSendException; nested exceptions (0) are:
org.springframework.mail.MailSendException; nested exceptions (0) are:
Caused by: javax.mail.NoSuchProviderException: No provider for mail
        at javax.mail.Session.getProvider(Session.java:455)
        at javax.mail.Session.getTransport(Session.java:650)
        at javax.mail.Session.getTransport(Session.java:631)
        at
org.springframework.mail.javamail.JavaMailSenderImpl.getTransport(JavaMailSenderImpl.java:419)
        at
org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:378)

Any idea about this exception?

Thank you again!

Bertrand.
http://www.odelia-technologies.com/




James.Strachan wrote:
> 
> On 9/17/07, bgoetzmann <[EMAIL PROTECTED]> wrote:
>>
>> Thank you James.
>>
>> Using the Java code you indicated:
>>
>> MailComponent component = new MailComponent();
>> component.getConfiguration().setHost("myMailServerHost");
>> ...
>>
>> Does the instance must be put in a Camel context? Like this:
>> camelContext.put("mail", component);
> 
> Yes, or...
> 
>> Sorry, I don't see the relation with JNDI, and the URI I can use like in
>> my
>> sample code.
>> Must I use something like ... .to(smtp://...) or ... .to(mail: ...)?
> 
> So when you use a URI in camel, it tries to find the endpoint in your
> registry (which is usually the ApplicationContext if you're a spring
> user or JNDI if not). Then if it can't find it, it takes the scheme
> (mail, or smtp, pop3 or whatever) and tries to find a Component in the
> register for that -if it does it then asks the Component to make the
> endpoint.
> 
> You can avoid the use of a Registry if you prefer and just put your
> components/endpoints into the CamelContext directly.
> 
> 
>> > so if you are using spring you could do something like
>> >
>> > <bean id="mail" class="org.apache.camel.component.mail.MailComponent">
>> >   <property name="configuration">
>> >    <bean class="org.apache.camel.component.mail.MailConfiguration">
>> >      <property name="host" value="myMailServerHost">
>> > ...
> 
> So in this example the "mail" entry in the ApplicationContext will
> point to the configured mail compnent.
> 
> 
>> > or if you are using Java code and not using spring you could add a
>> > configured MailComponent into JNDI
>> >
>> >
>> > MailComponent component = new MailComponent();
>> > component.getConfiguration().setHost("myMailServerHost");
>> > context.put("mail", component);
> 
> Here we're adding the component into the initial JNDI context so that
> the CamelContext can resolve "mail" endpoints.
> 
> The use of the registry is optional really; its really just there to
> let folks use whatever they are already using (like JNDI in some app
> server or Spring etc) to configure things.
> 
> -- 
> James
> -------
> http://macstrac.blogspot.com/
> 
> 
:-):-)
-- 
View this message in context: 
http://www.nabble.com/Sending-an-email-with-Camel-tf4443341s22882.html#a12784890
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to