Class MailServiceImpl

java.lang.Object
org.exoplatform.services.mail.impl.MailServiceImpl
All Implemented Interfaces:
MailService

public class MailServiceImpl extends Object implements MailService
Basically this is MailService implementation build on top of javax.mail package. You may define the behaviour of the service via InitParams, which can be set in configuration file of the ExoContainer.

Note: To be able to send mails you must provide active SMTP server and mention it in service configuration.

Created by The eXo Platform SAS Author : Phung Hai Nam phunghainam@gmail.com Dec 23, 2005

  • Constructor Details

    • MailServiceImpl

      public MailServiceImpl(org.exoplatform.container.xml.InitParams params, org.exoplatform.container.ExoContainerContext ctx) throws Exception
      Throws:
      Exception
  • Method Details

    • getMailSession

      public javax.mail.Session getMailSession()
      Provides Session instance, which is to be used throughout MailService methods
      Specified by:
      getMailSession in interface MailService
      Returns:
      Session
    • getOutgoingMailServer

      public String getOutgoingMailServer()
      Provides outgoing server information, which is basically its hostname or ip address. This server is used as transceiver for mail messages. MailService should send message to the server first and than server will resend messages to the receivers.
      Specified by:
      getOutgoingMailServer in interface MailService
      Returns:
    • sendMessage

      public void sendMessage(String from, String to, String subject, String body) throws Exception
      Sends mail message based on passed String parameters.
      Specified by:
      sendMessage in interface MailService
      Parameters:
      from - - String identificator of mail sender. For example 'test.sender@test.test'
      to - - String identificator of mail receiver. For example 'test.receiver@test.test'
      subject - - String subject of mail message
      body - - String contents of mail message
      Throws:
      Exception - is thrown if something's gone wrong during mail send procedure
    • sendMessage

      public void sendMessage(Message message) throws Exception
      Sends mail message based on Message instance
      Specified by:
      sendMessage in interface MailService
      Parameters:
      message - - Message provides mail message related data (e.g. subject, content etc.)
      Throws:
      Exception - is thrown if something's gone wrong during mail send procedure
    • sendMessage

      public void sendMessage(javax.mail.internet.MimeMessage message) throws Exception
      Sends mail message based on MimeMessage instance
      Specified by:
      sendMessage in interface MailService
      Parameters:
      message - - MimeMessage provides mail message related data (e.g. subject, content etc.)
      Throws:
      Exception - is thrown if something's gone wrong during mail send procedure
    • sendMessageInFuture

      public Future<Boolean> sendMessageInFuture(String from, String to, String subject, String body)
      Asynchronous variant of MailService.sendMessage(String, String, String, String). Returns Future object, which allows to track mail sending result. Calling Future.get() for this object returns Boolean.TRUE if mail is sent successfully, throws ExecutionException if some exception occured during mail sending. Calling Throwable.getCause() for the thrown exception object provides the exception, which indeed occured during sending mail.
      Specified by:
      sendMessageInFuture in interface MailService
      Parameters:
      from - - String identificator of mail sender. For example 'test.sender@test.test'
      to - - String identificator of mail receiver. For example 'test.receiver@test.test'
      subject - - String subject of mail message
      body - - String contents of mail message
      Returns:
      Future object to watch the result of asynchronous calculation
    • sendMessageInFuture

      public Future<Boolean> sendMessageInFuture(Message message)
      Asynchronous variant of MailService.sendMessage(Message). Returns Future object, which allows to track mail sending result. Calling Future.get() for this object returns Boolean.TRUE if mail is sent successfully, throws ExecutionException if some exception occured during mail sending. Calling Throwable.getCause() for the thrown exception object provides the exception, which indeed occured during sending mail.
      Specified by:
      sendMessageInFuture in interface MailService
      Parameters:
      message - - Message provides mail message related data (e.g. subject, content etc.)
      Returns:
      Future object to watch the result of asynchronous calculation
    • sendMessageInFuture

      public Future<Boolean> sendMessageInFuture(javax.mail.internet.MimeMessage message)
      Asynchronous variant of MailService.sendMessage(MimeMessage). Returns Future object, which allows to track mail sending result. Calling Future.get() for this object returns Boolean.TRUE if mail is sent successfully, throws ExecutionException if some exception occured during mail sending. Calling Throwable.getCause() for the thrown exception object provides the exception, which indeed occured during sending mail.
      Specified by:
      sendMessageInFuture in interface MailService
      Parameters:
      message - - MimeMessage provides mail message related data (e.g. subject, content etc.)
      Returns:
      Future object to watch the result of asynchronous calculation
    • getArrs

      protected String[] getArrs(String toArray)