Section 8.7. Deploying JavaMail on JBoss


8.7. Deploying JavaMail on JBoss

We now need to configure JBoss so we can use it as a JavaMail provider. JBoss manages a JavaMail Session as a JMX MBean that creates the Session and registers its JNDI name. The JBoss JavaMail XML descriptor, $JBOSS_HOME/server/jbossatwork/deploy/mail-service.xml, sets up a JMX MBean that configures a JNDI-based JavaMail Session in Example 8-8.

Example 8-8. mail-service.xml
 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE server> <server>   <mbean code="org.jboss.mail.MailService"          name="jboss:service=Mail">     <attribute name="JNDIName">java:/Mail</attribute>     <attribute name="User">yourUserId</attribute>     <attribute name="Password">yourPassword</attribute>     <attribute name="Configuration">        <configuration>           <!-- Set the protocol for your mail server -->           <property name="mail.store.protocol" value="pop3"/>           <property name="mail.transport.protocol" value="smtp"/>           <!-- Configure the POP3 Server  -->           <property name="mail.pop3.host" value="yourIsp.pop3.host"/>           <!-- Configure the SMTP gateway server -->           <property name="mail.smtp.host" value="yourIsp.smtp.host "/>           <property name="mail.smtp.port" value="25"/>           <property name="mail.debug" value="true"/>        </configuration>     </attribute>   </mbean> </server> 

The mail-service.xml file configures a JavaMail Session with the email account properties that you use to connect with your email service provider:

  • Mail Store Protocol

  • Mail Transport Protocol

  • SMTP server name

  • POP server name

  • An email account user ID

  • An email account password

These are standard JavaMail properties, and you can find a complete listing of them in Appendix A of the JavaMail Design Specification at: http://java.sun.com/products/javamail/JavaMail-1.2.pdf.

The example above uses bogus values for its ISP settings, so you'll need to edit the $JBOSS_HOME/server/jbossatwork/deploy/mail-service.xml file and fill in the protocol and account settings you use to access your ISP's mail server. You could change the JNDI name to something other than java:/Mail, but every JBoss installation we've seen uses this value to deploy its JavaMail Session. Therefore we recommend sticking with the default value to be consistent with the way most people use JBoss.



JBoss at Work. A Practical Guide
JBoss at Work: A Practical Guide
ISBN: 0596007345
EAN: 2147483647
Year: 2004
Pages: 197

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net