Class EmailAPI

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

public final class EmailAPI extends Object
Email sender implementer API class. For email sending, an Email instance is necessary, which will be sent. The email server's can be given parameters in the Email instance, or can be stored in messages, that will have to be loaded by the application, by using the MessageSourceAPI.
Since:
4.0
Author:
JBStrap
See Also:
  • Method Details

    • prepareEmail

      public static Email prepareEmail()
      Creates a new empty Email object
      Returns:
      The created email object
      See Also:
    • prepareEmail

      public static Email prepareEmail(boolean setFromResource)
      Creates a new Email object. If setFromResource parameter is true, then the mail object parameters made from messages. These parameters can be overwritten, in the created Email object.
      The parameter keys read from the MessageSourceAPI:
      host: mail.smtp.host
      port: mail.smtp.port
      socketFactoryPort: mail.smtp.socketFactory.port
      socketFactoryClass: mail.smtp.socketFactory.class
      starttlsEnable: mail.smtp.starttls.enable
      transportProtocol: mail.transport.protocol
      sslEnable: mail.smtp.ssl.enable
      sslTrust: mail.smtp.ssl.trust
      auth: mail.smtp.auth
      userName: mail.smtp.username
      password: mail.smtp.password
      debugEnabled: mail.debug.enabled
      Parameters:
      setFromResource - Set email parameters from message source or not
      Returns:
      The created email object
      See Also:
    • sendMail

      public static void sendMail(Email email) throws javax.mail.internet.AddressException, javax.mail.MessagingException, UnsupportedEncodingException
      Sends an Email, that is created by calling the prepareEmail method
      Parameters:
      email - The parameters needed for sending the Email, and the instance containing the email itself (host, port, auth, from, to, subject, ...).
      Throws:
      javax.mail.internet.AddressException - Occurs if either address is wrong, cannot be parsed.
      UnsupportedEncodingException - Occurs if the name that is to be displayed can't be set, due to a character encoding error
      javax.mail.MessagingException - Occurs if any other error is encountered during the email sending process.