Class Mailing

java.lang.Object
com.saperion.common.mail.Mailing

public class Mailing extends Object

A mail util class for convenient SMTP mailing.

This implementation is not synchronized. If used by different threads concurrently, external synchronization is necessary.

Author:
sts
  • Field Details

  • Constructor Details

  • Method Details

    • testSmtpConnect

      public void testSmtpConnect() throws javax.mail.MessagingException
      Performs a test SMTP connect. This can be done to test, if the mail configuration is correct. No mail is send, only a connect is performed.
      Throws:
      javax.mail.MessagingException - if the test-connect did not succeed.
    • isInitialized

      public boolean isInitialized()
      Indicates if this instance was initialized properly and can be used. Note: this indication does only mean that a SMTP session could be created with the present configuration. If you want to check if a SMTP connect is working, please call the method testSMTPConnect.
      Returns:
      true, if this instance was initialized properly, false otherwise.
    • sendMail

      public void sendMail(String fromAddress, String fromName, String to, String subject, String text) throws javax.mail.MessagingException, UnsupportedEncodingException, MailConfigurationException
      Sends a mail by the given parameters. The mail content is encoded as "text/html" in "utf-8" always.
      Parameters:
      fromAddress - the sender's mail address. May not be null or empty.
      fromName - the sender's name. May not be null or empty.
      to - the receiver's mail address. May not be null or empty.
      subject - the mail subject. May not be null or empty.
      text - the mail body. May not be null or empty.
      Throws:
      javax.mail.MessagingException - if the mail could not be sent.
      UnsupportedEncodingException - if the mail could not be sent due to an EncodingException.
      MailConfigurationException - if this instance was not initialized properly.