CopaServer
Change of Plan Application
 All Classes Functions Pages
Public Member Functions | Static Public Attributes | List of all members
unicopa.copa.server.email.EmailService Class Reference

With the E-Mail Service it is possible to send E-Mails for notifications of updates. More...

Collaboration diagram for unicopa.copa.server.email.EmailService:
Collaboration graph

Public Member Functions

 EmailService (Properties smtpProps, Map< String, InputStream > texts, FileHandler logFH)
 Create a new EmailService. More...
 
void postMail (String recipient, String subject, String message)
 Sends a simple plain-text E-Mail. More...
 
void notifySingleEventUpdate (List< EmailContext > contexts, UpdateInformation info)
 Sends E-Mails to notify the given recipients of the SingelEventUpdate. More...
 

Static Public Attributes

static final Logger LOG
 

Detailed Description

With the E-Mail Service it is possible to send E-Mails for notifications of updates.

Author
Philip Wendland

Constructor & Destructor Documentation

unicopa.copa.server.email.EmailService.EmailService ( Properties  smtpProps,
Map< String, InputStream >  texts,
FileHandler  logFH 
)

Create a new EmailService.

Parameters
smtpPropsthe environment properties used by the JavaMail API. The path to the file is "/email/smtp.properties". You should provide mail.smtp.host - specifies the host address of the SMTP-Server you wish to use, e.g. smtp.example.com mail.smtp.auth - specifies, whether authentication is necessary in order to be able to connect to the SMTP-Server (true/false - true in most cases) mail.smtp.port - specifies the port of the SMTP-Server to connect to, e.g. 587 mail.from - specifies the return E-Mail address of the sent E-Mail, i.e. info@.nosp@m.exam.nosp@m.ple.c.nosp@m.om username - the username of the user (if mail.smtp.auth=true) password - the password of the user (if mail.smtp.auth=true) for the EmailService to work properly.
textsa Map of <String, InputStream> where the key is a (String-)identifier for the specific template which is read from the InputStream. The path to the files is "/email/templates/". The name of the file is for example "default_newAppointment_english.txt" (see the email configuration folder for more information) The following example shows the format of the text template: The first line is the E-Mail subject line The message body begins with the second line. You can add expressions from unicopa.copa.server.email.TextPatterns (i.e. _UPDATE_DATE, _CREATOR_NAME, _COMMENT, _LOCATION, _DATE, _SUPERVISOR, _EVENTGROUP_NAME, _EVENT_NAME). These expressions will be replaced by the data from the SingleEventUpdate before sending E-Mails with the method notifySingleEventUpdate. This will also work in the subject line!
See Also
unicopa.copa.server.email.TextPattern

Member Function Documentation

void unicopa.copa.server.email.EmailService.notifySingleEventUpdate ( List< EmailContext contexts,
UpdateInformation  info 
)

Sends E-Mails to notify the given recipients of the SingelEventUpdate.

Note: The format of the E-Mail depends on the data obtained from the parameter "update" and the "TextID" obtained from the parameter contexts. For each TextID there should be one entry in the "texts" parameter which was passed to the constructor when you created your EmailContext object.

Parameters
contextsa list of EmailContexts (Containing E-Mail-Addresses and TextID's)
infothe information that should be passed to the recipients
Exceptions
MessagingException
See Also
unicopa.copa.server.email.UpdateInformation
unicopa.copa.server.email.EmailContext
void unicopa.copa.server.email.EmailService.postMail ( String  recipient,
String  subject,
String  message 
)

Sends a simple plain-text E-Mail.

Parameters
recipientthe recipient the E-Mail should be sent to, i.e. x@y.c.nosp@m.om
subjectthe subject of the E-Mail
messagethe plain-text body of the E-Mail
Exceptions
MessagingException

Member Data Documentation

final Logger unicopa.copa.server.email.EmailService.LOG
static
Initial value:
= Logger.getLogger(EmailService.class
.getName())

The documentation for this class was generated from the following file: