Introduction

Obviously each deployment of the EJB will need to configure the mail server that it is to used as well as several other properties. Being an EJB this is most easily done through the component's JNDI environment.

How to configure

The following JNDI settings may be configured in several ways:

  • By supplying an alternative EJB deployment descriptor when deploying the EJB as part of an Enterprise ARchive (.ear)
  • By using a runtime configuration console either supplied by your J2EE container vendor or a Third Party.
  • By modifying of the ejb-jar.xml file (or one of the J2EE container specific extension files) prior to deployment.
  • As XDoclet tags in the source code which is picked when XDoclet is run.

Your exact choice from the above options will be determined by the features of the container you are using and your development methodology. I have listed them in my own order of preference, - after all one of the declared advantages of EJBs is the ability to integrate solutions made up of discrete components.

What to configure

The following table explains the purpose of each JNDI variable.

Variable name Variable description Example
HOST The mail host's name mail.tpg.com.au
PROTOCOL The mail host's protocol for outgoing mail. SMTP is the only protocol to have been tested, though the JavaMail API for providers theoretically supports others. smtp
USER The username to authenticate on the mail host tstephen
PASSWD The password for the username supplied above mypassword
FROM The default address the message will appear to be from. The sendMail method can override this value. Tim
DEBUG Whether or not the JavaMail classes should print debug messages during sending. Boolean.TRUE
MBOX Always use the default value, since no mailbox reading facility has yet been added to the EJB. INBOX
SEND Always use the default value. send
MAILER Always use the default value. msgsend