org.sakaiproject.component.framework.email
Class BasicEmailService

java.lang.Object
  extended byorg.sakaiproject.component.framework.email.BasicEmailService
All Implemented Interfaces:
EmailService

public class BasicEmailService
extends Object
implements EmailService

BasicEmailService implements the EmailService.

See the EmailService interface for details.

Author:
Sakai Software Development Team

Nested Class Summary
protected  class BasicEmailService.MyMessage
           
 
Field Summary
protected static String CONTENT_TYPE
           
protected  Logger m_logger
          Dependency: logging service.
protected  ServerConfigurationService m_serverConfigurationService
          Dependency: ServerConfigurationService.
protected  String m_smtp
          Configuration: smtp server to use.
protected  String m_smtpFrom
          Configuration: optional smtp mail envelope return address.
protected  String m_smtpPort
          Configuration: smtp server port to use.
protected static String POSTMASTER
           
protected static String SMTP_FROM
           
protected static String SMTP_HOST
           
protected static String SMTP_PORT
           
 
Constructor Summary
BasicEmailService()
           
 
Method Summary
protected static boolean canUseCharset(String content, String charsetName)
          Returns true if the given content String can be encoded in the given charset
 void destroy()
          Final cleanup.
 void init()
          Final initialization, once all dependencies are set.
 void send(String fromStr, String toStr, String subject, String content, String headerToStr, String replyToStr, List additionalHeaders)
          Creates and sends a generic text MIME message to the address contained in to.
 void sendMail(InternetAddress from, InternetAddress[] to, String subject, String content, InternetAddress[] headerTo, InternetAddress[] replyTo, List additionalHeaders)
          Creates and sends a generic text MIME message to the address contained in to.
 void setLogger(Logger service)
          Dependency: logging service.
 void setServerConfigurationService(ServerConfigurationService service)
          Dependency: ServerConfigurationService.
 void setSmtp(String value)
          Configuration: smtp server to use.
 void setSmtpFrom(String value)
          Configuration: smtp mail envelope return address.
 void setSmtpPort(String value)
          Configuration: smtp server port to use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

POSTMASTER

protected static final String POSTMASTER
See Also:
Constant Field Values

SMTP_HOST

protected static final String SMTP_HOST
See Also:
Constant Field Values

SMTP_PORT

protected static final String SMTP_PORT
See Also:
Constant Field Values

SMTP_FROM

protected static final String SMTP_FROM
See Also:
Constant Field Values

CONTENT_TYPE

protected static final String CONTENT_TYPE
See Also:
Constant Field Values

m_logger

protected Logger m_logger
Dependency: logging service.


m_serverConfigurationService

protected ServerConfigurationService m_serverConfigurationService
Dependency: ServerConfigurationService.


m_smtp

protected String m_smtp
Configuration: smtp server to use.


m_smtpPort

protected String m_smtpPort
Configuration: smtp server port to use.


m_smtpFrom

protected String m_smtpFrom
Configuration: optional smtp mail envelope return address.

Constructor Detail

BasicEmailService

public BasicEmailService()
Method Detail

setLogger

public void setLogger(Logger service)
Dependency: logging service.

Parameters:
service - The logging service.

setServerConfigurationService

public void setServerConfigurationService(ServerConfigurationService service)
Dependency: ServerConfigurationService.

Parameters:
service - The ServerConfigurationService.

setSmtp

public void setSmtp(String value)
Configuration: smtp server to use.

Parameters:
value - The smtp server string.

setSmtpPort

public void setSmtpPort(String value)
Configuration: smtp server port to use.

Parameters:
value - The smtp server port string.

setSmtpFrom

public void setSmtpFrom(String value)
Configuration: smtp mail envelope return address.

Parameters:
value - The smtp mail from address string.

init

public void init()
Final initialization, once all dependencies are set.


destroy

public void destroy()
Final cleanup.


sendMail

public void sendMail(InternetAddress from,
                     InternetAddress[] to,
                     String subject,
                     String content,
                     InternetAddress[] headerTo,
                     InternetAddress[] replyTo,
                     List additionalHeaders)
Creates and sends a generic text MIME message to the address contained in to.

Specified by:
sendMail in interface EmailService
Parameters:
from - The address this message is to be listed as coming from.
to - The address(es) this message should be sent to.
subject - The subject of this message.
content - The body of the message.
replyTo - If specified, this is the reply to header address(es).
additionalHeaders - Additional email headers to send (List of String). For example, content type or forwarded headers (may be null)

canUseCharset

protected static boolean canUseCharset(String content,
                                       String charsetName)
Returns true if the given content String can be encoded in the given charset


send

public void send(String fromStr,
                 String toStr,
                 String subject,
                 String content,
                 String headerToStr,
                 String replyToStr,
                 List additionalHeaders)
Creates and sends a generic text MIME message to the address contained in to.

Specified by:
send in interface EmailService
Parameters:
fromStr - The address this message is to be listed as coming from.
toStr - The address(es) this message should be sent to.
subject - The subject of this message.
content - The body of the message.
headerToStr - If specified, this is placed into the message header, but "too" is used for the recipients.
replyToStr - If specified, the reply-to header value.
additionalHeaders - Additional email headers to send (List of String). For example, content type or forwarded headers (may be null)