Class SFSPostOffice

java.lang.Object
com.smartfoxserver.entities.managers.SFSPostOffice
All Implemented Interfaces:
com.smartfoxserver.bitswarm.service.IService, IMailerService

public class SFSPostOffice extends Object implements IMailerService
SFSPostOffice provides a simple mailing service for sending text/html emails via a configured SMTP service. SMPT ports supported are 25, 587 and 465 (SSL). The service can be configured via the SmartFoxServer AdminTool GUI.

You can access the service via the following line of code:


 	getApi().getMailService();
 

In order to ensure proper communication between SmartFoxServer and the SMTP server make sure to double check your hosting firewall settings and verify that traffic is allowed for the specified TCP port.

There are three modes for sending an email:

  • No notice send: simply sends the email right away
  • Callback send: you provide a callback object 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
NOTE: as with any other email system there is no 100% guarantee of delivery even when the callback reports a success. The success notification simply indicates that SmartFoxServer was able to contact the SMTP server and deliver the message to it. The email might then be filtered by an anti-spam system, or get refused because the recipient inbox is full etc...

Additional NOTE: The system is based on the excellent Simple Java Mail library If necessary you can completely bypass our PostOffice service and build your own mailing system with this API.

  • Constructor Details

    • SFSPostOffice

      public SFSPostOffice()
  • Method Details

    • init

      public void init(Object o)
      Specified by:
      init in interface com.smartfoxserver.bitswarm.service.IService
      Internal
    • destroy

      public void destroy(Object o)
      Specified by:
      destroy in interface com.smartfoxserver.bitswarm.service.IService
      Internal
    • getName

      public String getName()
      Specified by:
      getName in interface com.smartfoxserver.bitswarm.service.IService
      Internal
    • getConfiguration

      public com.smartfoxserver.config.MailerSettings getConfiguration()
      Obtain the configuration settings of the service
      Specified by:
      getConfiguration in interface IMailerService
      Returns:
      the configuration settings of the service
    • sendMail

      public void sendMail(Email email, IMailerCallbackHandler callBack) throws org.simplejavamail.MailException
      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 Simple Mail core module(found under lib/sjm/coremodule-x.y.z.jar) to your project's libraries.

      Specified by:
      sendMail in interface IMailerService
      Parameters:
      email - the email to send
      callBack - the callback handler, if null no event will be fired
      Throws:
      org.simplejavamail.MailException - an error might be caused by malformed email addresses either in the TO or FROM fields
      See Also:
    • sendMail

      public void sendMail(Email email) throws org.simplejavamail.MailException
      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 Simple Mail core module(found under lib/sjm/coremodule-x.y.z.jar) to your project's libraries.

      Specified by:
      sendMail in interface IMailerService
      Parameters:
      email - the email to send
      Throws:
      org.simplejavamail.MailException - an error might be caused by malformed email addresses either in the TO or FROM fields
      See Also:
    • sendMail

      public void sendMail(Email email, IMailerCallbackHandler callBack, int delaySeconds) throws org.simplejavamail.MailException
      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 Simple Mail core module(found under lib/sjm/coremodule-x.y.z.jar) to your project's libraries.

      Specified by:
      sendMail in interface IMailerService
      Parameters:
      email - the email to send
      callBack - the callback handler, if null no event will be fired
      delaySeconds - the amount of seconds to wait before sendint the mail
      Throws:
      org.simplejavamail.MailException - an error might be caused by malformed email addresses either in the TO or FROM fields
      See Also:
    • handleMessage

      public void handleMessage(Object message)
      Specified by:
      handleMessage in interface com.smartfoxserver.bitswarm.service.IService
      Internal
    • setName

      public void setName(String name)
      Specified by:
      setName in interface com.smartfoxserver.bitswarm.service.IService
      Internal