Package com.jbstrap.core.mail
Class Email
java.lang.Object
com.jbstrap.core.mail.Email
Class repesenting an Email. In this class the email parameters can be applied, so that the
EmailAPI
class can later use it.
Not only the email parameters can be processed, but the mail server settings can also be specified here.- Since:
- 4.0
- Author:
- JBStrap
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddAttachment
(File... files) Adds the file(s) to the EmailaddAttachment
(String filename, File file) Adds the specified file to the attachments.addAttachment
(Map<String, File> files) Adds the specified file to the attachments.addBodyPart
(String contentId, File part) addBodyPart
(String contentId, InputStream part, String mimeType) copy()
Copy the Email object to the new Email instancedeleteBodyPart
(String contentId) Gets the email attachment filesList<javax.mail.BodyPart>
getHost()
Gets the Email server hostGets a list of the Email bcc addresseesGets the Email bodyGets the Email body text
If the email client can't display HTML, then this is the content that will be visible instead of themailBody
Gets a list of the Email cc addresseesGets the Email sender's addressGets the mail sender's display nameGets the Email subjectGets a list of the Email addresseesGets the Email server authentication passwordint
getPort()
Gets the Email server portGets the Email reply to addresseesGets the Email server socket factory classint
Gets the Email server socket factory portGets the Email server SSL trustGets the Email server transport protocolGets the Email server authentication usernameboolean
isAuth()
Determines if the Email server authentication is enabledboolean
Determines if the Email server debug mode is enabledboolean
Determines if the Email server SSL is enabledboolean
Determines if the Email server start TLS is enabled or notsetAuth
(boolean auth) Sets the Email server authenticationsetDebugEnabled
(boolean debugEnabled) Enables the Email server debug modeSets the Email server hostsetMailBcc
(String... mailBcc) Sets the Email bcc addresseessetMailBcc
(List<String> mailBcc) Sets a list of the Email bcc addresseessetMailBody
(String mailBody) Sets the Email bodysetMailBodyText
(String mailBodyText) Sets the Email body text
If the email client can't display HTML, then this is the content that will be visible instead of themailBody
Sets the Email cc addresseesSets a list of the Email cc addresseessetMailFrom
(String mailFrom) Sets the Email sender's addresssetMailFromDisplayName
(String mailFromDisplayName) Sets the mail sender's display namesetMailSubject
(String mailSubject) Sets the Email subjectSets the Email addresseesSets the Email addressees (using a list)setPassword
(String password) Sets the Email server authentication passwordsetPort
(int port) Sets the Email server portsetReplyTo
(String... replyTo) Sets the Email reply to addresseessetReplyTo
(List<String> replyTo) Sets the Email reply to addresseessetSocketFactoryClass
(String socketFactoryClass) Sets the Email server socket factory classsetSocketFactoryPort
(int socketFactoryPort) Sets the Email server socket factory portsetSslEnable
(boolean sslEnable) Enables the Email server SSLsetSslTrust
(String sslTrust) Sets the Email server SSL trustsetStarttlsEnable
(boolean starttlsEnable) Enables the Email server start TLSsetTransportProtocol
(String transportProtocol) Sets the Email server transport protocolsetUserName
(String userName) Sets the Email server authentication username
-
Constructor Details
-
Email
public Email()
-
-
Method Details
-
getHost
Gets the Email server host- Returns:
- Email server host
-
setHost
Sets the Email server host- Parameters:
host
- The Email server host- Returns:
- The Email object
-
getPort
public int getPort()Gets the Email server port- Returns:
- Email server port
-
setPort
Sets the Email server port- Parameters:
port
- Email server port- Returns:
- The Email object
-
getSocketFactoryPort
public int getSocketFactoryPort()Gets the Email server socket factory port- Returns:
- Email server socket factory port
-
setSocketFactoryPort
Sets the Email server socket factory port- Parameters:
socketFactoryPort
- Email server socket factory port- Returns:
- The Email object
-
getSocketFactoryClass
Gets the Email server socket factory class- Returns:
- Email server socket factory class
-
setSocketFactoryClass
Sets the Email server socket factory class- Parameters:
socketFactoryClass
- Email server socket factory class- Returns:
- The Email object
-
isStarttlsEnable
public boolean isStarttlsEnable()Determines if the Email server start TLS is enabled or not- Returns:
true
if the Email server start TLS is enabled
-
setStarttlsEnable
Enables the Email server start TLS- Parameters:
starttlsEnable
- Email server start TLS status- Returns:
- The Email object
-
getTransportProtocol
Gets the Email server transport protocol- Returns:
- Email server transport protocol
-
setTransportProtocol
Sets the Email server transport protocol- Parameters:
transportProtocol
- Email server transport protocol- Returns:
- The Email object
-
isSslEnable
public boolean isSslEnable()Determines if the Email server SSL is enabled- Returns:
true
if the Email server SSL is enabled
-
setSslEnable
Enables the Email server SSL- Parameters:
sslEnable
- Email server SSL status- Returns:
- The Email object
-
getSslTrust
Gets the Email server SSL trust- Returns:
- Email server SSL trust
-
setSslTrust
Sets the Email server SSL trust- Parameters:
sslTrust
- Email server SSL trust- Returns:
- The Email object
-
isAuth
public boolean isAuth()Determines if the Email server authentication is enabled- Returns:
true
if the Email server authentication is enabled
-
setAuth
Sets the Email server authentication- Parameters:
auth
- Email server authentication status- Returns:
- The Email object
-
getUserName
Gets the Email server authentication username- Returns:
- The Email server authentication username
-
setUserName
Sets the Email server authentication username- Parameters:
userName
- Email server authentication username- Returns:
- The Email object
-
getPassword
Gets the Email server authentication password- Returns:
- The Email server authentication password
-
setPassword
Sets the Email server authentication password- Parameters:
password
- The Email server authentication password- Returns:
- The Email object
-
isDebugEnabled
public boolean isDebugEnabled()Determines if the Email server debug mode is enabled- Returns:
true
if the Email server debug mode is enabled
-
setDebugEnabled
Enables the Email server debug mode- Parameters:
debugEnabled
- The debug mode status- Returns:
- The Email object
-
getMailFrom
Gets the Email sender's address- Returns:
- The Email sender's address
-
setMailFrom
Sets the Email sender's address- Parameters:
mailFrom
- Email sender address- Returns:
- The Email object
-
getMailFromDisplayName
Gets the mail sender's display name- Returns:
- The mail sender's display name
-
setMailFromDisplayName
Sets the mail sender's display name- Parameters:
mailFromDisplayName
- The mail sender's display name- Returns:
- The Email object
-
getMailSubject
Gets the Email subject- Returns:
- The Email subject
-
setMailSubject
Sets the Email subject- Parameters:
mailSubject
- Email subject- Returns:
- The Email object
-
getMailBody
Gets the Email body- Returns:
- The Email body
-
setMailBody
Sets the Email body- Parameters:
mailBody
- The Email body- Returns:
- The Email object
-
getMailBodyText
Gets the Email body text
If the email client can't display HTML, then this is the content that will be visible instead of themailBody
- Returns:
- The Email body text
-
setMailBodyText
Sets the Email body text
If the email client can't display HTML, then this is the content that will be visible instead of themailBody
- Parameters:
mailBodyText
- The Email body text- Returns:
- The Email object
-
addBodyPart
- Throws:
javax.mail.MessagingException
-
addBodyPart
public Email addBodyPart(String contentId, InputStream part, String mimeType) throws javax.mail.MessagingException, IOException - Throws:
javax.mail.MessagingException
IOException
-
getBodyPars
-
deleteBodyPart
-
deleteAllBodyPart
-
getMailTo
Gets a list of the Email addressees- Returns:
- Email addressees
-
setMailTo
Sets the Email addressees- Parameters:
mailTo
- Email addressees- Returns:
- The Email object
-
setMailTo
Sets the Email addressees (using a list)- Parameters:
mailTo
- Email addressees- Returns:
- The Email object
-
getMailCc
Gets a list of the Email cc addressees- Returns:
- The Email cc addressees
-
setMailCc
Sets the Email cc addressees- Parameters:
mailCc
- The Email cc addressees- Returns:
- The Email object
-
setMailCc
Sets a list of the Email cc addressees- Parameters:
mailCc
- The Email cc addressees- Returns:
- The Email object
-
getMailBcc
Gets a list of the Email bcc addressees- Returns:
- A list of the Email bcc addressees
-
setMailBcc
Sets the Email bcc addressees- Parameters:
mailBcc
- The Email bcc addressees- Returns:
- The Email object
-
setMailBcc
Sets a list of the Email bcc addressees- Parameters:
mailBcc
- The Email bcc addressees- Returns:
- The Email object
-
getReplyTo
Gets the Email reply to addressees- Returns:
- The Email reply to addressees
-
setReplyTo
Sets the Email reply to addressees- Parameters:
replyTo
- The Email reply to addressees- Returns:
- The Email object
-
setReplyTo
Sets the Email reply to addressees- Parameters:
replyTo
- The Email reply to addressees- Returns:
- The Email object
-
addAttachment
Adds the specified file to the attachments.- Parameters:
filename
- The attached file's name in the emailfile
- The file to be attached- Returns:
- Email object
-
addAttachment
Adds the file(s) to the Email- Parameters:
files
- The file(s) that will be added to the email- Returns:
- The Email object
-
addAttachment
Adds the specified file to the attachments.- Parameters:
files
- The files to be attached- Returns:
- Email object
-
getAttachments
Gets the email attachment files- Returns:
- A map of the attached files. The map key is the filename, the value is the file. If no file was attached, it will return with an empty map
-
copy
Copy the Email object to the new Email instance- Returns:
- The copied email object
-