org.enableit.tools.email.ejb
Class EmailBean

java.lang.Object
  |
  +--org.enableit.tools.email.ejb.EmailBean
Direct Known Subclasses:
EmailAdapter

public class EmailBean
extends java.lang.Object

An EJB for sending email.

Author:
Tim Stephenson
See Also:
Main documentation

Field Summary
static java.lang.String ABOUT
          CVS info about this class and its current version
static java.lang.String MT_BINARY
          A valid message content type
static java.lang.String MT_HTML
          A valid message content type
static java.lang.String MT_PLAIN_TEXT
          A valid message content type
 
Constructor Summary
EmailBean()
          Default constructor.
 
Method Summary
 void ejbCreate()
          Called by container when creating new bean instance.
protected  void initialise()
          Initialise the bean configurations from JNDI tree.
protected  void initialise(java.lang.String protocol, java.lang.String mbox, java.lang.String send, java.lang.String host, java.lang.String user, java.lang.String passwd, java.lang.String mailer, java.lang.String from, java.lang.Boolean debug, java.lang.String blankSubject)
          Initialise the bean configurations from params.
 void sendEmail(EmailConfigBean bean)
          Sends an email made up of a message and an attachment.
 void sendEmail(java.lang.String to, java.lang.String from, java.lang.String subject, java.lang.String message)
          Sends an email message using the Mail server configured in the JNDI environment.
 void sendEmail(java.lang.String to, java.lang.String from, java.lang.String subject, java.lang.String message, java.lang.String attachmentText)
          Sends an email message using the Mail server configured in the JNDI environment and creates an attachment too.
 void sendEmail(java.lang.String to, java.lang.String from, java.lang.String subject, java.lang.String message, java.net.URL attachmentUrl)
          Sends an email made up of a message and an attachment.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MT_PLAIN_TEXT

public static final java.lang.String MT_PLAIN_TEXT
A valid message content type

MT_HTML

public static final java.lang.String MT_HTML
A valid message content type

MT_BINARY

public static final java.lang.String MT_BINARY
A valid message content type

ABOUT

public static final java.lang.String ABOUT
CVS info about this class and its current version
Constructor Detail

EmailBean

public EmailBean()
Default constructor. This is the only constructor allowable for an EJB
Method Detail

ejbCreate

public void ejbCreate()
               throws javax.ejb.CreateException,
                      javax.ejb.EJBException
Called by container when creating new bean instance.
See Also:
EJB spec

initialise

protected void initialise()
Initialise the bean configurations from JNDI tree.

initialise

protected void initialise(java.lang.String protocol,
                          java.lang.String mbox,
                          java.lang.String send,
                          java.lang.String host,
                          java.lang.String user,
                          java.lang.String passwd,
                          java.lang.String mailer,
                          java.lang.String from,
                          java.lang.Boolean debug,
                          java.lang.String blankSubject)
Initialise the bean configurations from params.

This method is really only intended for testing purposes, though it could also be used to initialise this class as a simple class, rather than an EJB.

Parameters:
protocol - The mail protocol to configure with.
mbox - Not used since no mailbox is ever read.
send - JavaMail property 'send'
host - The outgoing mail host.
user - User to authenticate with on the outgoing mail server.
passwd - Password (plain text) to authenticate with on the outgoing mail server.
mailer - JavaMail property 'mailer'
from - Default for the mail 'from' field if not provided on send.
debug - Whether to use a debug mail session.
blankSubject - The subject to use when the caller of sendEmail does not provide one (may be blank but may not be null).

sendEmail

public void sendEmail(java.lang.String to,
                      java.lang.String from,
                      java.lang.String subject,
                      java.lang.String message)
               throws java.rmi.RemoteException
Sends an email message using the Mail server configured in the JNDI environment.
Parameters:
to - Target email address.
from - Message 'from' address. If supplied this overrides the default in the JNDI context.
subject - Subject for the mail message.
message - Body text for the mail message.
Throws:
java.rmi.RemoteException - System exception, notably misconfiguration of mail server.

sendEmail

public void sendEmail(java.lang.String to,
                      java.lang.String from,
                      java.lang.String subject,
                      java.lang.String message,
                      java.lang.String attachmentText)
               throws java.rmi.RemoteException
Sends an email message using the Mail server configured in the JNDI environment and creates an attachment too.
Parameters:
to - Target email address.
from - Message 'from' address. If supplied this overrides the default in the JNDI context.
subject - Subject for the mail message.
message - Body text for the mail message.
attachmentText - Text to create as a text/plain attachment.
Throws:
java.rmi.RemoteException - System exception, notably misconfiguration of mail server.

sendEmail

public void sendEmail(java.lang.String to,
                      java.lang.String from,
                      java.lang.String subject,
                      java.lang.String message,
                      java.net.URL attachmentUrl)
               throws java.rmi.RemoteException
Sends an email made up of a message and an attachment. Converts a URL reference to an InputStream. The URL must be accessible using the http(s) protocol.
Parameters:
to - Target email address.
from - Message 'from' address. If supplied this overrides the default in the JNDI context.
subject - Subject for the mail message.
message - Body text for the mail message.
attachmentUrl - URL to fetch and create as an attachment.
Throws:
java.rmi.RemoteException - System exception, notably misconfiguration of mail server.

sendEmail

public void sendEmail(EmailConfigBean bean)
               throws java.rmi.RemoteException
Sends an email made up of a message and an attachment. Converts a URL reference to an InputStream. The URL must be accessible using the http(s) protocol.
Parameters:
bean - An EmailConfigBean containing all the details for the message.
Throws:
java.rmi.RemoteException - System exception, notably misconfiguration of mail server.


Copyright © 1999-2003 enableIT.org. All Rights Reserved.