Package org.exoplatform.services.mail
Interface MailService
- All Known Implementing Classes:
MailServiceImpl
public interface MailService
Interface provides basic operations for sending mail messages and mail service
configuration data retrieval. Defines synchronous and asynchronous methods
responsible for sending mail message. They can receive parameters of different types
to create a mail send. You can pass
Message, MimeMessage
or specify mail message data explicitly via String parameters.-
Method Summary
Modifier and TypeMethodDescriptionjavax.mail.SessionProvidesSessioninstance, which is to be used throughoutMailServicemethodsProvides 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 onMessageinstancesendMessageInFuture(String from, String to, String subject, String body) Asynchronous variant ofsendMessage(String, String, String, String).sendMessageInFuture(javax.mail.internet.MimeMessage message) Asynchronous variant ofsendMessage(MimeMessage).sendMessageInFuture(Message message) Asynchronous variant ofsendMessage(Message).
-
Method Details
-
getMailSession
javax.mail.Session getMailSession()ProvidesSessioninstance, which is to be used throughoutMailServicemethods- Returns:
Session
-
getOutgoingMailServer
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.- Returns:
-
sendMessage
Sends mail message based on passedStringparameters.- 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
Sends mail message based onMessageinstance -
sendMessage
Sends mail message based onMimeMessageinstance- 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
Asynchronous variant ofsendMessage(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.- 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
Asynchronous variant ofsendMessage(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. -
sendMessageInFuture
Asynchronous variant ofsendMessage(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.- Parameters:
message- -MimeMessageprovides mail message related data (e.g. subject, content etc.)- Returns:
Futureobject to watch the result of asynchronous calculation
-