camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james.strac...@gmail.com>
Subject Re: Sending an email with Camel
Date Sat, 15 Sep 2007 07:33:42 GMT
So the idea is that things like host names of your mail server or JMS
server can be configured on a Component, then the endpoints don't have
to have all that configuration in them. e.g. a mail endpoint can be
just the email address; or a JMS endpoint can be just the queue/topic
name etc.

http://activemq.apache.org/camel/endpoint.html
http://activemq.apache.org/camel/component.html


So the idea is you can configure the component with things like JMS
ConnectionFactory, or JPA EntityManagerFactory or whatnot; then just
use the endpoints as nice and simple URIs. So in the case of the mail
component you can configure the MailComponent with all the various
connection details via the MailConfiguration POJO which has a bunch of
setters for things like the host/port of your mail server etc.

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">
...


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);


On 9/14/07, bgoetzmann <bgoetzmann@sophia.symag.com> wrote:
>
> Thank you.
> Yes I saw this file ; but how define this property and others (the "from" or
> "suject") using Java DSL?
>
> Here my test class:
>
>
> public class Test {
>
>         /**
>          * @param args
>          * @throws Exception
>          */
>         public static void main(String[] args) throws Exception {
>                 CamelContext context = new DefaultCamelContext();
>
>                 context.addRoutes(new RouteBuilder() {
>
>                     public void configure() {
>                         from("timer:myTimerEvent?fixedRate=true&delay=0&period=1000")
>                                   // this works!
>                         //.setBody(Builder.constant("Salut !")).to("log:test");
>
>                                   // How define smtp host?
>                         .setBody(Builder.constant("Salut
> !")).to("smtp://bgoetzmann@sophia.symag.com");
>
>                     }
>
>                 });
>
>                 context.start();
>
>                 Thread.sleep(5000);
>
>         }
>
> }
>
>
>
> Frank Lynch-2 wrote:
> >
> > Hi Bertrand,
> > I believe "ausernam@ahost" is the address to which the email will be
> > delivered.
> > You can set the SMTP server via a properties object eg:
> >
> >         Properties properties = new Properties();
> >         properties.put("mail.smtp.host", "localhost");
> >         mailSession = Session.getInstance(properties, null);
> >
> > This code fragment was taken from MailMessageTest.java in:
> >  /components/camel-mail/src/test/java/org/apache/camel/component/mail/
> > HTH,
> > --Frank
> >
> >
> >
> > On Fri, 2007-09-14 at 08:32 -0700, bgoetzmann wrote:
> >> Hi,
> >>
> >> Camel is a very interesting project ! Thank you for all developers of
> >> this
> >> project.
> >>
> >> Trying a first Java application I would like to send emails using a route
> >> ;
> >> so I try something like
> >>
> >> ... .to("smtp://ausernam@ahost")
> >>
> >> but is ausernam@ahost must be a address mail at witch you send the mail?
> >> How
> >> can I specify the smtp server?
> >>
> >> I appreciate an example.
> >>
> >> Thank you!
> >>
> >> Bertrand.
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Sending-an-email-with-Camel-tf4443341s22882.html#a12678558
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>


-- 
James
-------
http://macstrac.blogspot.com/

Mime
View raw message