Package org.opennms.javamail
Class JavaMailer2
- java.lang.Object
-
- org.opennms.javamail.JavaMailer2
-
- Direct Known Subclasses:
JavaReadMailer,JavaSendMailer
public abstract class JavaMailer2 extends java.lang.ObjectSends an email message using the Java Mail API- Version:
- $Id: $
- Author:
- David Hustace
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJavaMailer2.LoggingByteArrayOutputStreamlogstatic classJavaMailer2.LoggingTransportListener
-
Constructor Summary
Constructors Constructor Description JavaMailer2()Default constructor.JavaMailer2(java.util.Properties javamailProps)Constructor for JavaMailer2.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.mail.AuthenticatorcreateAuthenticator(java.lang.String user, java.lang.String password)Helper method to create an Authenticator based on Password Authenticationjavax.mail.internet.MimeBodyPartcreateFileAttachment(java.io.File file)Create a file attachment as a MimeBodyPart, checking to see if the file exists before we create the attachment.java.util.PropertiesgetMailProps()This returns the properties configured in the javamail-configuration.properties file.javax.mail.SessiongetSession()getSessionvoidsetDebug(boolean debug)setDebugvoidsetSession(javax.mail.Session session)setSession
-
-
-
Constructor Detail
-
JavaMailer2
public JavaMailer2(java.util.Properties javamailProps) throws JavaMailerExceptionConstructor for JavaMailer2.
- Parameters:
javamailProps- aPropertiesobject.- Throws:
JavaMailerException- if any.
-
JavaMailer2
public JavaMailer2() throws JavaMailerExceptionDefault 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:
java.io.IOException- if any.JavaMailerException- if any.
-
-
Method Detail
-
createAuthenticator
public javax.mail.Authenticator createAuthenticator(java.lang.String user, java.lang.String password)Helper method to create an Authenticator based on Password Authentication- Parameters:
user- aStringobject.password- aStringobject.- Returns:
- a
Authenticatorobject.
-
createFileAttachment
public javax.mail.internet.MimeBodyPart createFileAttachment(java.io.File file) throws javax.mail.MessagingException, JavaMailerExceptionCreate 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:
javax.mail.MessagingException- if we can't set the data handler or the file name on the MimeBodyPartJavaMailerException- if the file does not exist or is not readable
-
setDebug
public void setDebug(boolean debug)
setDebug
- Parameters:
debug- a boolean.
-
getSession
public javax.mail.Session getSession()
getSession
- Returns:
- the session
-
setSession
public void setSession(javax.mail.Session session)
setSession
- Parameters:
session- the session to set
-
getMailProps
public java.util.Properties getMailProps()
This returns the properties configured in the javamail-configuration.properties file.- Returns:
- a
Propertiesobject.
-
-