Package org.opennms.javamail
Class JavaSendMailer
- java.lang.Object
-
- org.opennms.javamail.JavaMailer2
-
- org.opennms.javamail.JavaSendMailer
-
public class JavaSendMailer extends JavaMailer2
Use this class for sending e-mails.Crude extension of JavaMailer
TODO: Improve class hierarchy
TODO: Needs testing
- Author:
- David Hustace
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.opennms.javamail.JavaMailer2
JavaMailer2.LoggingByteArrayOutputStream, JavaMailer2.LoggingTransportListener
-
-
Constructor Summary
Constructors Constructor Description JavaSendMailer(SendmailConfig config)Instantiates a new java send mailer.JavaSendMailer(SendmailConfig config, boolean useJmProps)Instantiates a new java send mailer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.mail.internet.MimeMessagebuildMimeMessage(SendmailMessage msg)Builds the mime message.javax.mail.AuthenticatorcreateAuthenticator()Creates the authenticator.SendmailConfiggetConfig()Gets the sendmail configuration.javax.mail.internet.MimeMessagegetMessage()Gets the message.PropertiesgetProperties()Gets the properties.voidsend()Send.voidsend(javax.mail.internet.MimeMessage message)Send.voidsetConfig(SendmailConfig config)Sets the sendmail configuration.voidsetMessage(javax.mail.internet.MimeMessage message)Sets the message.voidsetProperties(Properties properties)Sets the properties.-
Methods inherited from class org.opennms.javamail.JavaMailer2
createAuthenticator, createFileAttachment, getMailProps, getSession, setDebug, setSession
-
-
-
-
Constructor Detail
-
JavaSendMailer
public JavaSendMailer(SendmailConfig config, boolean useJmProps) throws JavaMailerException
Instantiates a new java send mailer.Constructs everything required to call send().
- Parameters:
config- the sendmail configurationuseJmProps- a boolean representing the handling of the deprecated javamail-configuration.properties file.- Throws:
JavaMailerException- the java mailer exception
-
JavaSendMailer
public JavaSendMailer(SendmailConfig config) throws JavaMailerException
Instantiates a new java send mailer.Using this constructor implies overriding sendmail configuration with properties from the deprecated javamail-configuration.properties file.
- Parameters:
config- the sendmail configuration- Throws:
JavaMailerException- the java mailer exception
-
-
Method Detail
-
buildMimeMessage
public javax.mail.internet.MimeMessage buildMimeMessage(SendmailMessage msg)
Builds the mime message.- Parameters:
msg- the sendmail message- Returns:
- the mime message
-
createAuthenticator
public javax.mail.Authenticator createAuthenticator()
Creates the authenticator.- Returns:
- the authenticator
-
send
public void send() throws JavaMailerExceptionSend.- Throws:
JavaMailerException- the java mailer exception
-
send
public void send(javax.mail.internet.MimeMessage message) throws JavaMailerExceptionSend.- Parameters:
message- the message- Throws:
JavaMailerException- the java mailer exception
-
setConfig
public void setConfig(SendmailConfig config)
Sets the sendmail configuration.- Parameters:
config- the new sendmail configuration
-
getConfig
public SendmailConfig getConfig()
Gets the sendmail configuration.- Returns:
- the sendmail configuration
-
setMessage
public void setMessage(javax.mail.internet.MimeMessage message)
Sets the message.- Parameters:
message- the new message
-
getMessage
public javax.mail.internet.MimeMessage getMessage()
Gets the message.- Returns:
- the message
-
setProperties
public void setProperties(Properties properties)
Sets the properties.- Parameters:
properties- the new properties
-
getProperties
public Properties getProperties()
Gets the properties.- Returns:
- the properties
-
-