Class MailServiceImpl
- java.lang.Object
-
- org.exoplatform.services.mail.impl.MailServiceImpl
-
- All Implemented Interfaces:
MailService
public class MailServiceImpl extends Object implements MailService
Basically this isMailServiceimplementation build on top of javax.mail package. You may define the behaviour of the service viaInitParams, which can be set in configuration file of theExoContainer.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 Summary
Constructors Constructor Description MailServiceImpl(org.exoplatform.container.xml.InitParams params, org.exoplatform.container.ExoContainerContext ctx)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String[]getArrs(String toArray)javax.mail.SessiongetMailSession()ProvidesSessioninstance, which is to be used throughoutMailServicemethodsStringgetOutgoingMailServer()Provides outgoing server information, which is basically its hostname or ip address.voidsendMessage(String from, String to, String subject, String body)Sends mail message based on passedStringparameters.voidsendMessage(javax.mail.internet.MimeMessage message)Sends mail message based onMimeMessageinstancevoidsendMessage(Message message)Sends mail message based onMessageinstanceFuture<Boolean>sendMessageInFuture(String from, String to, String subject, String body)Asynchronous variant ofMailService.sendMessage(String, String, String, String).Future<Boolean>sendMessageInFuture(javax.mail.internet.MimeMessage message)Asynchronous variant ofMailService.sendMessage(MimeMessage).Future<Boolean>sendMessageInFuture(Message message)Asynchronous variant ofMailService.sendMessage(Message).
-
-
-
Method Detail
-
getMailSession
public javax.mail.Session getMailSession()
ProvidesSessioninstance, which is to be used throughoutMailServicemethods- Specified by:
getMailSessionin interfaceMailService- 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.MailServiceshould send message to the server first and than server will resend messages to the receivers.- Specified by:
getOutgoingMailServerin interfaceMailService- Returns:
-
sendMessage
public void sendMessage(String from, String to, String subject, String body) throws Exception
Sends mail message based on passedStringparameters.- Specified by:
sendMessagein interfaceMailService- Parameters:
from- -Stringidentificator of mail sender. For example 'test.sender@test.test'to- -Stringidentificator of mail receiver. For example 'test.receiver@test.test'subject- -Stringsubject of mail messagebody- -Stringcontents 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 onMessageinstance- Specified by:
sendMessagein interfaceMailService- Parameters:
message- -Messageprovides 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 ExceptionSends mail message based onMimeMessageinstance- Specified by:
sendMessagein interfaceMailService- Parameters:
message- -MimeMessageprovides 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 ofMailService.sendMessage(String, String, String, String). ReturnsFutureobject, which allows to track mail sending result. CallingFuture.get()for this object returnsBoolean.TRUEif mail is sent successfully, throwsExecutionExceptionif some exception occured during mail sending. CallingThrowable.getCause()for the thrown exception object provides the exception, which indeed occured during sending mail.- Specified by:
sendMessageInFuturein interfaceMailService- Parameters:
from- -Stringidentificator of mail sender. For example 'test.sender@test.test'to- -Stringidentificator of mail receiver. For example 'test.receiver@test.test'subject- -Stringsubject of mail messagebody- -Stringcontents of mail message- Returns:
Futureobject to watch the result of asynchronous calculation
-
sendMessageInFuture
public Future<Boolean> sendMessageInFuture(Message message)
Asynchronous variant ofMailService.sendMessage(Message). ReturnsFutureobject, which allows to track mail sending result. CallingFuture.get()for this object returnsBoolean.TRUEif mail is sent successfully, throwsExecutionExceptionif some exception occured during mail sending. CallingThrowable.getCause()for the thrown exception object provides the exception, which indeed occured during sending mail.- Specified by:
sendMessageInFuturein interfaceMailService- Parameters:
message- -Messageprovides mail message related data (e.g. subject, content etc.)- Returns:
Futureobject to watch the result of asynchronous calculation
-
sendMessageInFuture
public Future<Boolean> sendMessageInFuture(javax.mail.internet.MimeMessage message)
Asynchronous variant ofMailService.sendMessage(MimeMessage). ReturnsFutureobject, which allows to track mail sending result. CallingFuture.get()for this object returnsBoolean.TRUEif mail is sent successfully, throwsExecutionExceptionif some exception occured during mail sending. CallingThrowable.getCause()for the thrown exception object provides the exception, which indeed occured during sending mail.- Specified by:
sendMessageInFuturein interfaceMailService- Parameters:
message- -MimeMessageprovides mail message related data (e.g. subject, content etc.)- Returns:
Futureobject to watch the result of asynchronous calculation
-
-