You can send email to an EmailListener by calling sendEmailEvent() on the listener, passing it a EmailEvent containing the email you want to send. Typically, a service broadcasts an EmailEvent to all of its attached EmailListener objects. For example, the following code defines a service to be a source of Email events and shows how to broadcast an EmailEvent to the listeners of that event:

Vector emailListeners = new Vector ();
public void addEmailListener (EmailListener listener) {
  emailListeners.addElement (listener);
public void removeEmailListener (EmailListener listener) {
  emailListeners.removeElement (listener);
public EmailListener [] getEmailListeners () {
  EmailListener [] ret = new EmailListener [emailListeners.size ()];
  emailListeners.copyInto (ret);
  return ret;
public void broadcastEmailEvent (EmailEvent event) {
  for (int i = 0; i < emailListeners.size (); i++) {
    try {
      ((EmailListener) (emailListeners.elementAt (i))).sendEmailEvent (event);
    catch (EmailException exc) {}

The properties file configuring your service can then hook up the listeners of the email events like this:


Now, when you call broadcastEmailEvent, your email is sent through the /atg/dynamo/service/SMTPEmail component, which sends the email.