org.opennms.javamail
Class JavaMailer2

java.lang.Object
  extended by org.opennms.javamail.JavaMailer2
Direct Known Subclasses:
JavaReadMailer, JavaSendMailer

public abstract class JavaMailer2
extends Object

Sends an email message using the Java Mail API

Author:
David Hustace

Nested Class Summary
static class JavaMailer2.LoggingByteArrayOutputStream
           
static class JavaMailer2.LoggingTransportListener
           
 
Constructor Summary
JavaMailer2()
          Default constructor.
JavaMailer2(Properties javamailProps)
           
 
Method Summary
 Authenticator createAuthenticator(String user, String password)
          Helper method to create an Authenticator based on Password Authentication
 MimeBodyPart createFileAttachment(File file)
          Create a file attachment as a MimeBodyPart, checking to see if the file exists before we create the attachment.
 Properties getMailProps()
          This returns the properties configured in the javamail-configuration.properties file.
 Session getSession()
           
protected  Category log()
           
 void setDebug(boolean debug)
           
 void setSession(Session session)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaMailer2

public JavaMailer2(Properties javamailProps)
            throws JavaMailerException
Throws:
JavaMailerException

JavaMailer2

public JavaMailer2()
            throws JavaMailerException
Default constructor. Default properties from javamailer-properties are set into session. To change these properties, retrieve the current properties from the session and override as needed.

Throws:
IOException
JavaMailerException
Method Detail

createAuthenticator

public Authenticator createAuthenticator(String user,
                                         String password)
Helper method to create an Authenticator based on Password Authentication

Returns:

createFileAttachment

public MimeBodyPart createFileAttachment(File file)
                                  throws MessagingException,
                                         JavaMailerException
Create a file attachment as a MimeBodyPart, checking to see if the file exists before we create the attachment.

Parameters:
file - file to attach
Returns:
attachment body part
Throws:
MessagingException - if we can't set the data handler or the file name on the MimeBodyPart
JavaMailerException - if the file does not exist or is not readable

setDebug

public void setDebug(boolean debug)

log

protected Category log()
Returns:
log4j Category

getSession

public Session getSession()
Returns:
the session

setSession

public void setSession(Session session)
Parameters:
session - the session to set

getMailProps

public Properties getMailProps()
This returns the properties configured in the javamail-configuration.properties file.

Returns:


Copyright © 2009. All Rights Reserved.