Class Email

java.lang.Object
com.jbstrap.core.mail.Email

public class Email extends Object
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 Details

    • Email

      public Email()
  • Method Details

    • getHost

      public String getHost()
      Gets the Email server host
      Returns:
      Email server host
    • setHost

      public Email setHost(String host)
      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

      public Email setPort(int port)
      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

      public Email setSocketFactoryPort(int socketFactoryPort)
      Sets the Email server socket factory port
      Parameters:
      socketFactoryPort - Email server socket factory port
      Returns:
      The Email object
    • getSocketFactoryClass

      public String getSocketFactoryClass()
      Gets the Email server socket factory class
      Returns:
      Email server socket factory class
    • setSocketFactoryClass

      public Email setSocketFactoryClass(String socketFactoryClass)
      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

      public Email setStarttlsEnable(boolean starttlsEnable)
      Enables the Email server start TLS
      Parameters:
      starttlsEnable - Email server start TLS status
      Returns:
      The Email object
    • getTransportProtocol

      public String getTransportProtocol()
      Gets the Email server transport protocol
      Returns:
      Email server transport protocol
    • setTransportProtocol

      public Email setTransportProtocol(String transportProtocol)
      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

      public Email setSslEnable(boolean sslEnable)
      Enables the Email server SSL
      Parameters:
      sslEnable - Email server SSL status
      Returns:
      The Email object
    • getSslTrust

      public String getSslTrust()
      Gets the Email server SSL trust
      Returns:
      Email server SSL trust
    • setSslTrust

      public Email setSslTrust(String sslTrust)
      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

      public Email setAuth(boolean auth)
      Sets the Email server authentication
      Parameters:
      auth - Email server authentication status
      Returns:
      The Email object
    • getUserName

      public String getUserName()
      Gets the Email server authentication username
      Returns:
      The Email server authentication username
    • setUserName

      public Email setUserName(String userName)
      Sets the Email server authentication username
      Parameters:
      userName - Email server authentication username
      Returns:
      The Email object
    • getPassword

      public String getPassword()
      Gets the Email server authentication password
      Returns:
      The Email server authentication password
    • setPassword

      public Email setPassword(String password)
      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

      public Email setDebugEnabled(boolean debugEnabled)
      Enables the Email server debug mode
      Parameters:
      debugEnabled - The debug mode status
      Returns:
      The Email object
    • getMailFrom

      public String getMailFrom()
      Gets the Email sender's address
      Returns:
      The Email sender's address
    • setMailFrom

      public Email setMailFrom(String mailFrom)
      Sets the Email sender's address
      Parameters:
      mailFrom - Email sender address
      Returns:
      The Email object
    • getMailFromDisplayName

      public String getMailFromDisplayName()
      Gets the mail sender's display name
      Returns:
      The mail sender's display name
    • setMailFromDisplayName

      public Email setMailFromDisplayName(String mailFromDisplayName)
      Sets the mail sender's display name
      Parameters:
      mailFromDisplayName - The mail sender's display name
      Returns:
      The Email object
    • getMailSubject

      public String getMailSubject()
      Gets the Email subject
      Returns:
      The Email subject
    • setMailSubject

      public Email setMailSubject(String mailSubject)
      Sets the Email subject
      Parameters:
      mailSubject - Email subject
      Returns:
      The Email object
    • getMailBody

      public String getMailBody()
      Gets the Email body
      Returns:
      The Email body
    • setMailBody

      public Email setMailBody(String mailBody)
      Sets the Email body
      Parameters:
      mailBody - The Email body
      Returns:
      The Email object
    • getMailBodyText

      public String 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 the mailBody
      Returns:
      The Email body text
    • setMailBodyText

      public Email setMailBodyText(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 the mailBody
      Parameters:
      mailBodyText - The Email body text
      Returns:
      The Email object
    • addBodyPart

      public Email addBodyPart(String contentId, File part) throws javax.mail.MessagingException
      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

      public List<javax.mail.BodyPart> getBodyPars()
    • deleteBodyPart

      public Email deleteBodyPart(String contentId)
    • deleteAllBodyPart

      public Email deleteAllBodyPart()
    • getMailTo

      public List<String> getMailTo()
      Gets a list of the Email addressees
      Returns:
      Email addressees
    • setMailTo

      public Email setMailTo(String... mailTo)
      Sets the Email addressees
      Parameters:
      mailTo - Email addressees
      Returns:
      The Email object
    • setMailTo

      public Email setMailTo(List<String> mailTo)
      Sets the Email addressees (using a list)
      Parameters:
      mailTo - Email addressees
      Returns:
      The Email object
    • getMailCc

      public List<String> getMailCc()
      Gets a list of the Email cc addressees
      Returns:
      The Email cc addressees
    • setMailCc

      public Email setMailCc(String... mailCc)
      Sets the Email cc addressees
      Parameters:
      mailCc - The Email cc addressees
      Returns:
      The Email object
    • setMailCc

      public Email setMailCc(List<String> mailCc)
      Sets a list of the Email cc addressees
      Parameters:
      mailCc - The Email cc addressees
      Returns:
      The Email object
    • getMailBcc

      public List<String> getMailBcc()
      Gets a list of the Email bcc addressees
      Returns:
      A list of the Email bcc addressees
    • setMailBcc

      public Email setMailBcc(String... mailBcc)
      Sets the Email bcc addressees
      Parameters:
      mailBcc - The Email bcc addressees
      Returns:
      The Email object
    • setMailBcc

      public Email setMailBcc(List<String> mailBcc)
      Sets a list of the Email bcc addressees
      Parameters:
      mailBcc - The Email bcc addressees
      Returns:
      The Email object
    • getReplyTo

      public List<String> getReplyTo()
      Gets the Email reply to addressees
      Returns:
      The Email reply to addressees
    • setReplyTo

      public Email setReplyTo(String... replyTo)
      Sets the Email reply to addressees
      Parameters:
      replyTo - The Email reply to addressees
      Returns:
      The Email object
    • setReplyTo

      public Email setReplyTo(List<String> replyTo)
      Sets the Email reply to addressees
      Parameters:
      replyTo - The Email reply to addressees
      Returns:
      The Email object
    • addAttachment

      public Email addAttachment(String filename, File file)
      Adds the specified file to the attachments.
      Parameters:
      filename - The attached file's name in the email
      file - The file to be attached
      Returns:
      Email object
    • addAttachment

      public Email addAttachment(File... files)
      Adds the file(s) to the Email
      Parameters:
      files - The file(s) that will be added to the email
      Returns:
      The Email object
    • addAttachment

      public Email addAttachment(Map<String,File> files)
      Adds the specified file to the attachments.
      Parameters:
      files - The files to be attached
      Returns:
      Email object
    • getAttachments

      public Map<String,File> 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

      public Email copy()
      Copy the Email object to the new Email instance
      Returns:
      The copied email object