Package anlavn.net

Class Email

java.lang.Object
anlavn.net.Email

public class Email extends Object
The Email class supports create a SMTP to send email.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Email(String hostEmail, String hostPass)
    Create a host SMTP with full information.
    Email(String hostEmail, String hostPass, String hostServer)
    Create a host SMTP with full information.
    Email(String hostEmail, String hostPass, String hostServer, int hostPort)
    Create a host SMTP with full information.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Use this method to add attachments files to email.
    final boolean
    Use this method to add attachments files to email.
    final boolean
    addSetBCC(String... setBCC)
    Use this method to add recipients with type is BCC.
    final boolean
    addSetBCC(Set<String> setBCC)
    Use this method to add recipients with type is BCC.
    final boolean
    addSetCC(String... setCC)
    Use this method to add recipients with type is CC.
    final boolean
    Use this method to add recipients with type is CC.
    final boolean
    addSetTO(String... setTO)
    Use this method to add recipients with type is TO.
    final boolean
    Use this method to add recipients with type is TO.
    final void
    Use this method to clear content email include title, content email, TO, CC, BCC, Attachments.
    final void
    Use this method to clear set of attachments files.
    final void
    Use this method to clear set of recipients with type is BCC.
    final void
    Use this method to clear set of recipients with type is CC.
    final void
    Use this method to clear set of recipients with type is TO.
    final Set<String>
    Use this method to get set of attachments files.
    final Set<String>
    Use this method to get set of recipients with type is BCC.
    final Set<String>
    Use this method to get set of recipients with type is CC.
    final Set<String>
    Use this method to get set of recipients with type is TO.
    final void
    Use this method to send email to recipients.
    final void
    setEmail(String title, String content)
    Use this method to setup email content.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Email

      public Email(String hostEmail, String hostPass)
      Create a host SMTP with full information.
      Parameters:
      hostEmail - is your SMTP email address.
      hostPass - is your SMTP server passwords.
    • Email

      public Email(String hostEmail, String hostPass, String hostServer)
      Create a host SMTP with full information.
      Parameters:
      hostEmail - is your SMTP email address.
      hostPass - is your SMTP server passwords.
      hostServer - is your SMTP server address. Default is 'smtp.gmail.com'.
    • Email

      public Email(String hostEmail, String hostPass, String hostServer, int hostPort)
      Create a host SMTP with full information.
      Parameters:
      hostEmail - is your SMTP email address.
      hostPass - is your SMTP server passwords.
      hostServer - is your SMTP server address. Default is 'smtp.gmail.com'.
      hostPort - is port of your SMTP server. Default is '587'.
  • Method Details

    • setEmail

      public final void setEmail(String title, String content)
      Use this method to setup email content.
      Parameters:
      title - is Email Title.
      content - is Email Content.
    • addSetTO

      public final boolean addSetTO(String... setTO)
      Use this method to add recipients with type is TO.
      Parameters:
      setTO - is email address of recipients you want send to.
      Returns:
      true if this set changed.
    • addSetTO

      public final boolean addSetTO(Set<String> setTO)
      Use this method to add recipients with type is TO.
      Parameters:
      setTO - is email address of recipients you want send to.
      Returns:
      true if this set changed.
    • getSetTO

      public final Set<String> getSetTO()
      Use this method to get set of recipients with type is TO.
      Returns:
      set of address recipients with type is TO.
    • clearSetTO

      public final void clearSetTO()
      Use this method to clear set of recipients with type is TO.
    • addSetCC

      public final boolean addSetCC(String... setCC)
      Use this method to add recipients with type is CC.
      Parameters:
      setCC - is email address of recipients you want send carbon copy.
      Returns:
      true if this set changed.
    • addSetCC

      public final boolean addSetCC(Set<String> setCC)
      Use this method to add recipients with type is CC.
      Parameters:
      setCC - is email address of recipients you want send carbon copy.
      Returns:
      true if this set changed.
    • getSetCC

      public final Set<String> getSetCC()
      Use this method to get set of recipients with type is CC.
      Returns:
      set of recipients with type is CC.
    • clearSetCC

      public final void clearSetCC()
      Use this method to clear set of recipients with type is CC.
    • addSetBCC

      public final boolean addSetBCC(String... setBCC)
      Use this method to add recipients with type is BCC.
      Parameters:
      setBCC - is email address of recipients you want send blind carbon copy.
      Returns:
      true if this set changed.
    • addSetBCC

      public final boolean addSetBCC(Set<String> setBCC)
      Use this method to add recipients with type is BCC.
      Parameters:
      setBCC - is email address of recipients you want send blind carbon copy.
      Returns:
      true if this set changed.
    • getSetBCC

      public final Set<String> getSetBCC()
      Use this method to get set of recipients with type is BCC.
      Returns:
      set of recipients with type is BCC.
    • clearSetBCC

      public final void clearSetBCC()
      Use this method to clear set of recipients with type is BCC.
    • addSetAttachments

      public final boolean addSetAttachments(String... setFile)
      Use this method to add attachments files to email.
      Parameters:
      setFile - is attachments files you want send.
      Returns:
      true if this set changed.
    • addSetAttachments

      public final boolean addSetAttachments(Set<String> setFile)
      Use this method to add attachments files to email.
      Parameters:
      setFile - is attachments files you want send.
      Returns:
      true if this set changed.
    • getSetAttachments

      public final Set<String> getSetAttachments()
      Use this method to get set of attachments files.
      Returns:
      set of attachments files.
    • clearSetAttachments

      public final void clearSetAttachments()
      Use this method to clear set of attachments files.
    • clear

      public final void clear()
      Use this method to clear content email include title, content email, TO, CC, BCC, Attachments.
    • sendEmail

      public final void sendEmail() throws javax.mail.MessagingException
      Use this method to send email to recipients.
      Throws:
      javax.mail.MessagingException - throw an exception if there is no internet connection or can't send email to the recipient.