geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Boynes <jboy...@apache.org>
Subject Re: JavaMail
Date Mon, 22 Aug 2005 14:55:43 GMT
Neal Sanche wrote:
> 
> Well, I've looked through the source and found the 
> org.apache.geronimo.mail module. It seems to contain a few GBeans and 
> some tests. The tests are mostly empty. How would I create an SMTP 
> transport session from my code?
> 

The easiest way is to define a resource reference in the standard 
deployment descriptor:

   <resource-ref>
     <res-ref-name>mail/MailSession</res-ref-name>
     <res-type>javax.mail.Session</res-type>
     <res-auth>Container</res-auth>
     <res-sharing-scope>Shareable</res-sharing-scope>
   </resource-ref>

You can then look up the resource with code like:

     javax.mail.Session sess = (Session)
        new InitialContext().lookup("java:comp/env/mail/MailSession");

We don't provide a default session but you can define one using a GBean 
in your deployment plan:

     <gbean name="mail/MailSession"
       class="org.apache.geronimo.mail.SMTPTransportGBean">
         <attribute name="host">mail.example.com</attribute>
     </gbean>

Other attributes can be set as appropriate; I think we support all the 
"standard" mail.smtp ones and non-standard ones can be set through the 
"properties" attribute.

--
Jeremy

Mime
View raw message