org.olat.core.util.mail
Class Emailer

java.lang.Object
  extended by org.olat.core.util.mail.Emailer

public class Emailer
extends java.lang.Object

Helper class for sending emails. All mails sent by this class will have a footer that includes a link to this OLAT installation Initial Date: Feb 10, 2005

Author:
Sabina Jeger

Constructor Summary
Emailer(Identity mailFromIdentity, boolean tryInstitutionalEmail)
          Constructs an Emailer which derives its mail from address from the given Identity.
Emailer(java.util.Locale locale)
          Constructs an Emailer which derives its mail from address from the mailfrom configuration in OLATContext.
 
Method Summary
 boolean sendEmail(java.util.List listOfContactLists, java.lang.String subject, java.lang.String body)
          Creates a e-mail message with the given subject and body.
 boolean sendEmail(java.lang.String mailto, java.lang.String subject, java.lang.String body)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Emailer

public Emailer(java.util.Locale locale)
Constructs an Emailer which derives its mail from address from the mailfrom configuration in OLATContext. The mail host used to send the email is taken from the OLATContext

Parameters:
locale - locale that should be used for message localization

Emailer

public Emailer(Identity mailFromIdentity,
               boolean tryInstitutionalEmail)
Constructs an Emailer which derives its mail from address from the given Identity. The mail host used to send the email is taken from the OLATContext

The boolean parameter determines which email address is used.

Parameters:
mailFromIdentity - not null , containing the senders e-mail
tryInstitutionalEmail - specifies email address priority order
Method Detail

sendEmail

public boolean sendEmail(java.util.List listOfContactLists,
                         java.lang.String subject,
                         java.lang.String body)
                  throws javax.mail.internet.AddressException,
                         javax.mail.MessagingException
Creates a e-mail message with the given subject and body. The sender is taken from the value which was given to the constructor. The recipient fields TO: and BCC: are generated in the follwing manner:

Parameters:
listOfContactLists -
subject -
body -
Returns:
Throws:
javax.mail.MessagingException
javax.mail.internet.AddressException
javax.mail.MessagingException

sendEmail

public boolean sendEmail(java.lang.String mailto,
                         java.lang.String subject,
                         java.lang.String body)
                  throws javax.mail.internet.AddressException,
                         javax.mail.SendFailedException,
                         javax.mail.MessagingException
Parameters:
mailto -
subject -
body -
Returns:
Throws:
javax.mail.internet.AddressException
javax.mail.SendFailedException
javax.mail.MessagingException - TODO:gs handle exceptions internally and may return some error codes or so to get rid of dependecy of mail/activatoin jars in olat