public class JavaMailer extends Object
| Modifier and Type | Class and Description | 
|---|---|
static class  | 
JavaMailer.LoggingByteArrayOutputStream  | 
static class  | 
JavaMailer.LoggingTransportListener  | 
| Constructor and Description | 
|---|
JavaMailer()
Default constructor. 
 | 
JavaMailer(Properties javamailProps)
Constructor for JavaMailer. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
addExtraHeader(String key,
              String value)  | 
javax.mail.Message | 
buildMessage()
Build a complete message ready for sending. 
 | 
javax.mail.Authenticator | 
createAuthenticator()
Helper method to create an Authenticator based on Password Authentication 
 | 
javax.mail.internet.MimeBodyPart | 
createFileAttachment(File file)
Create a file attachment as a MimeBodyPart, checking to see if the file
 exists before we create the attachment. 
 | 
String | 
getCharSet()
getCharSet 
 | 
String | 
getContentType()
getContentType 
 | 
String | 
getEncoding()
getEncoding 
 | 
Map<String,String> | 
getExtraHeaders()  | 
String | 
getFileName()
getFileName 
 | 
String | 
getFrom()
getFrom 
 | 
InputStream | 
getInputStream()
getInputStream 
 | 
String | 
getInputStreamContentType()
getInputStreamContentType 
 | 
String | 
getInputStreamName()
getInputStreamName 
 | 
String | 
getMailer()
getMailer 
 | 
String | 
getMailHost()
getMailHost 
 | 
Properties | 
getMailProps()
This returns the properties configured in the javamail-configuration.properties file. 
 | 
String | 
getMessageText()
getMessageText 
 | 
String | 
getPassword()
getPassword 
 | 
String | 
getReplyTo()
getReplyTo 
 | 
javax.mail.Session | 
getSession()
getSession 
 | 
int | 
getSmtpPort()
getSmtpPort 
 | 
String | 
getSubject()
getSubject 
 | 
String | 
getTo()
getTo 
 | 
String | 
getTransport()
getTransport 
 | 
String | 
getUser()
getUser 
 | 
boolean | 
isAuthenticate()
isAuthenticate 
 | 
boolean | 
isDebug()
isDebug 
 | 
boolean | 
isQuitWait()
isQuitWait 
 | 
boolean | 
isSmtpSsl()
isSmtpSsl 
 | 
boolean | 
isStartTlsEnabled()
isStartTlsEnabled 
 | 
boolean | 
isUseJMTA()
isUseJMTA 
 | 
void | 
mailSend()
Sends a message based on properties set on this bean. 
 | 
void | 
sendMessage(javax.mail.Message message)
Send message. 
 | 
void | 
setAuthenticate(boolean authenticate)
setAuthenticate 
 | 
void | 
setCharSet(String charSet)
setCharSet 
 | 
void | 
setContentType(String contentType)
setContentType 
 | 
void | 
setDebug(boolean debug)
setDebug 
 | 
void | 
setEncoding(String encoding)
setEncoding 
 | 
void | 
setExtraHeaders(Map<String,String> headers)  | 
void | 
setFileName(String fileName)
setFileName 
 | 
void | 
setFrom(String from)
setFrom 
 | 
void | 
setInputStream(InputStream inputStream)
setInputStream 
 | 
void | 
setInputStreamContentType(String inputStreamContentType)
setInputStreamContentType 
 | 
void | 
setInputStreamName(String inputStreamName)
setInputStreamName 
 | 
void | 
setMailer(String mailer)
setMailer 
 | 
void | 
setMailHost(String mail_host)
setMailHost 
 | 
void | 
setMessageText(String messageText)
setMessageText 
 | 
void | 
setPassword(String password)
setPassword 
 | 
void | 
setQuitWait(boolean quitWait)
setQuitWait 
 | 
void | 
setSession(javax.mail.Session session)
setSession 
 | 
void | 
setSmtpPort(int smtpPort)
setSmtpPort 
 | 
void | 
setSmtpSsl(boolean smtpSsl)
setSmtpSsl 
 | 
void | 
setStartTlsEnabled(boolean startTlsEnabled)
setStartTlsEnabled 
 | 
void | 
setSubject(String subject)
setSubject 
 | 
void | 
setTo(String to)
setTo 
 | 
void | 
setTransport(String transport)
setTransport 
 | 
void | 
setUseJMTA(boolean useMTA)
setUseJMTA 
 | 
void | 
setUser(String user)
setUser 
 | 
public JavaMailer(Properties javamailProps) throws JavaMailerException
Constructor for JavaMailer.
javamailProps - a Properties object.JavaMailerException - if any.public JavaMailer()
           throws JavaMailerException
IOException - if any.JavaMailerException - if any.public void mailSend()
              throws JavaMailerException
JavaMailerException - if any.public javax.mail.Authenticator createAuthenticator()
Authenticator object.public javax.mail.Message buildMessage()
                                throws JavaMailerException
JavaMailerException - if any of the underlying operations failpublic javax.mail.internet.MimeBodyPart createFileAttachment(File file) throws javax.mail.MessagingException, JavaMailerException
file - file to attachjavax.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
      readablepublic void sendMessage(javax.mail.Message message)
                 throws JavaMailerException
message - a Message object.JavaMailerException - if any.public String getPassword()
getPassword
public void setPassword(String password)
setPassword
password - The password to set.public String getUser()
getUser
public void setUser(String user)
setUser
user - The user to set.public boolean isUseJMTA()
isUseJMTA
public void setUseJMTA(boolean useMTA)
setUseJMTA
useMTA - a boolean.public String getFrom()
getFrom
public String getReplyTo()
getReplyTo
public void setFrom(String from)
setFrom
from - The from address to set.public boolean isAuthenticate()
isAuthenticate
public void setAuthenticate(boolean authenticate)
setAuthenticate
authenticate - The authenticate boolean to set.public String getFileName()
getFileName
public void setFileName(String fileName)
setFileName
fileName - a String object.public InputStream getInputStream()
getInputStream
public void setInputStream(InputStream inputStream)
setInputStream
inputStream - Sets the input stream to be attached to the message.public String getInputStreamName()
getInputStreamName
public void setInputStreamName(String inputStreamName)
setInputStreamName
inputStreamName - Sets the name to use for stream attachments.public String getInputStreamContentType()
getInputStreamContentType
public void setInputStreamContentType(String inputStreamContentType)
setInputStreamContentType
inputStreamContentType - a String object.public String getMailHost()
getMailHost
public void setMailHost(String mail_host)
setMailHost
mail_host - Sets the mail host.public String getMailer()
getMailer
public void setMailer(String mailer)
setMailer
mailer - Sets the mailer.public String getMessageText()
getMessageText
public void setMessageText(String messageText)
setMessageText
messageText - Sets the message text.public String getSubject()
getSubject
public void setSubject(String subject)
setSubject
subject - Sets the message Subject.public String getTo()
getTo
public void setTo(String to)
setTo
to - Sets the To address.public void setTransport(String transport)
setTransport
transport - a String object.public boolean isDebug()
isDebug
public void setDebug(boolean debug)
setDebug
debug - a boolean.public javax.mail.Session getSession()
getSession
public void setSession(javax.mail.Session session)
setSession
session - the session to setpublic String getContentType()
getContentType
public void setContentType(String contentType)
setContentType
contentType - the contentType to setpublic String getCharSet()
getCharSet
public void setCharSet(String charSet)
setCharSet
charSet - the charSet to setpublic String getEncoding()
getEncoding
public void setEncoding(String encoding)
setEncoding
encoding - the encoding to setpublic boolean isStartTlsEnabled()
isStartTlsEnabled
public void setStartTlsEnabled(boolean startTlsEnabled)
setStartTlsEnabled
startTlsEnabled - the startTlsEnabled to setpublic boolean isQuitWait()
isQuitWait
public void setQuitWait(boolean quitWait)
setQuitWait
quitWait - the quitWait to setpublic int getSmtpPort()
getSmtpPort
public void setSmtpPort(int smtpPort)
setSmtpPort
smtpPort - the smtpPort to setpublic boolean isSmtpSsl()
isSmtpSsl
public void setSmtpSsl(boolean smtpSsl)
setSmtpSsl
smtpSsl - the smtpSsl to setpublic Properties getMailProps()
Properties object.Copyright © 2020. All rights reserved.