Class SFSPostOffice
- java.lang.Object
-
- com.smartfoxserver.v2.entities.managers.SFSPostOffice
-
- All Implemented Interfaces:
com.smartfoxserver.bitswarm.service.IService
,IMailerService
public class SFSPostOffice extends java.lang.Object implements IMailerService
SFSPostOffice is the default implementation of theIMailerService
which is provided by theSmartFoxServer
class- This service provides a simple mailing service capable of sending text and html emails via a configured SMTP service. SMPT ports supported are 25, 587 and 465 (SSL). The service can be configured via the SFS2X AdminTool GUI.You can obtain access to the service via the following line of code:
SmartFoxServer.getInstance().getMailService();
In order to ensure proper communication between SmartFoxServer and the SMTP server we make sure to double check your hosting firewall settings and make sure traffic is allowed on the chosen port.
There are three modalities for sending an email:
- No notice send: simply send the email in "hyperspace"
- Callback send: you provide a callback class that will be invoked once the email has been delivered. The callback notifies either the success of the operation or an exception with the details of what went wrong.
- Delayed send: you can specify a time in the future when the email should be sent
-
-
Constructor Summary
Constructors Constructor Description SFSPostOffice()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
destroy(java.lang.Object o)
Destroy servicecom.smartfoxserver.v2.config.MailerSettings
getConfiguration()
Obtain the configuration settings of the servicejava.lang.String
getName()
Get the service namevoid
handleMessage(java.lang.Object message)
Send message to servicevoid
init(java.lang.Object o)
Initialize servicevoid
sendMail(Email email)
Sends the email to the recipient, or list of recipients, specified in the Email argument.void
sendMail(Email email, IMailerCallbackHandler callBack)
Sends the email to the recipient, or list of recipients, specified in the Email argument and get an asynchronous event when the email is delivered.void
sendMail(Email email, IMailerCallbackHandler callBack, int delaySeconds)
Sends an email in the future.void
setName(java.lang.String name)
Set the service name
-
-
-
Method Detail
-
init
public void init(java.lang.Object o)
Description copied from interface:com.smartfoxserver.bitswarm.service.IService
Initialize service- Specified by:
init
in interfacecom.smartfoxserver.bitswarm.service.IService
- Parameters:
o
- custom parameters
-
destroy
public void destroy(java.lang.Object o)
Description copied from interface:com.smartfoxserver.bitswarm.service.IService
Destroy service- Specified by:
destroy
in interfacecom.smartfoxserver.bitswarm.service.IService
- Parameters:
o
- custom parameters
-
getName
public java.lang.String getName()
Description copied from interface:com.smartfoxserver.bitswarm.service.IService
Get the service name- Specified by:
getName
in interfacecom.smartfoxserver.bitswarm.service.IService
- Returns:
- the service name
-
getConfiguration
public com.smartfoxserver.v2.config.MailerSettings getConfiguration()
Obtain the configuration settings of the service- Specified by:
getConfiguration
in interfaceIMailerService
- Returns:
- the configuration settings of the service
-
sendMail
public void sendMail(Email email, IMailerCallbackHandler callBack) throws javax.mail.MessagingException
Sends the email to the recipient, or list of recipients, specified in the Email argument and get an asynchronous event when the email is delivered.In order to send an email to multiple recipients the Email toAddress should contain comma-separated (and valid) email addresses. Don't use any blank spaces in the separation of each address.
NOTE: Sending emails requires to add the mailapi.jar (found under SFS2X/lib/) to your project's libraries.
- Specified by:
sendMail
in interfaceIMailerService
- Parameters:
email
- the email to sendcallBack
- the callback handler, if null no event will be fired- Throws:
javax.mail.MessagingException
- an error might be caused by malformed email addresses either in the TO or FROM fields- See Also:
SFSEmail
-
sendMail
public void sendMail(Email email) throws javax.mail.MessagingException
Sends the email to the recipient, or list of recipients, specified in the Email argument.In order to send an email to multiple recipients the Email toAddress should contain comma-separated (and valid) email addresses. Don't use any blank spaces in the separation of each address.
NOTE: Sending emails requires to add the mailapi.jar (found under SFS2X/lib/) to your project's libraries.
- Specified by:
sendMail
in interfaceIMailerService
- Parameters:
email
- the email to send- Throws:
javax.mail.MessagingException
- an error might be caused by malformed email addresses either in the TO or FROM fields- See Also:
SFSEmail
-
sendMail
public void sendMail(Email email, IMailerCallbackHandler callBack, int delaySeconds) throws javax.mail.MessagingException
Sends an email in the future. The email can be sent to one recipient or a list of recipients specified in the Email argument. If a callback handler is provided the system will fire an asynchronous event when the email is delivered.In order to send an email to multiple recipients the Email toAddress should contain comma-separated (and valid) email addresses. Don't use any blank spaces in the separation of each address.
NOTE: Sending emails requires to add the mailapi.jar (found under SFS2X/lib/) to your project's libraries.
- Specified by:
sendMail
in interfaceIMailerService
- Parameters:
email
- the email to sendcallBack
- the callback handler, if null no event will be fireddelaySeconds
- the amount of seconds to wait before sendint the mail- Throws:
javax.mail.MessagingException
- an error might be caused by malformed email addresses either in the TO or FROM fields- See Also:
SFSEmail
-
handleMessage
public void handleMessage(java.lang.Object message)
Description copied from interface:com.smartfoxserver.bitswarm.service.IService
Send message to service- Specified by:
handleMessage
in interfacecom.smartfoxserver.bitswarm.service.IService
- Parameters:
message
- the message
-
setName
public void setName(java.lang.String name)
Description copied from interface:com.smartfoxserver.bitswarm.service.IService
Set the service name- Specified by:
setName
in interfacecom.smartfoxserver.bitswarm.service.IService
- Parameters:
name
- the service name
-
-