Thank you James. In our scenario we need to send a email to users to confirm
a registration process.
So the code changed from something like that:
...
.to("velocity:mail/UsuarioSolicitaRegistro.vm")
.setHeader("subject", constant("My subject"))
.to("smtp://[EMAIL PROTECTED]@fundacionctic.org")
to this:
...
.setHeader("to", el("${in.body.mail}"))
.to("velocity:mail/AdministradorValidaDominios.vm")
.setHeader("subject", constant("My subject"))
.recipientList(el("smtp://[EMAIL PROTECTED]"))
Quite easy. Anyway, i think the mail component would be somehow 'clearer' if
the recipient(s) could be passed in to a single endpoint within a header,
the same way as the subject.
BTW, great project !!
James.Strachan wrote:
>
> On 12/11/2007, ruben.martin <[EMAIL PROTECTED]> wrote:
>>
>> Now I need to decide the email recipient when i actually send the request
>> and
>> not in configuration time ( with the '[EMAIL PROTECTED]').
>> Is
>> there any way of specifying this address with a header in the same way
>> that
>> the subject?
>>
>> from("direct:a")
>> .to("smtp://[EMAIL PROTECTED]:[EMAIL PROTECTED]")
>>
>>
>> Exchange response = template.request("direct:a", new Processor()
>> {
>> public void process(Exchange exchange) throws Exception {
>> Message in = exchange.getIn();
>> in.setBody("------");
>> in.setHeader("subject", "My Subject");
>>
>> }
>> });
>
> So at runtime you can decide what endpoint URI to send to dynamically.
> e.g. this could be using a content based router...
>
> http://activemq.apache.org/camel/content-based-router.html
>
> or using a Dynamic Recipient List
>
> http://activemq.apache.org/camel/recipient-list.html
>
> where you use some expression to decide the endpoint URI using an
> expression.
>
> Finally you could just use a Bean which is injected with a
> ProducerTemplate to decide using Java code...
>
> public class MyBean implements Processor
> @EndpointInject(uri="someDefaultUri")
> ProducerTemplate template;
>
> public void process(Exchange exchange) {
> String uri = ...; // use some Java code to figure out the endpoint
> template.send(uri, exchange);
> }
> }
>
> then in the route do
>
> from("something").beanRef("myBean");
>
> for more info on using beans see
> http://activemq.apache.org/camel/bean-integration.html
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
> Open Source SOA
> http://open.iona.com
>
>
--
View this message in context:
http://www.nabble.com/How-to-send-a-mail-tf4787595s22882.html#a13745011
Sent from the Camel - Users mailing list archive at Nabble.com.