org.mycore.common
Class MCRMailer

java.lang.Object
  extended by org.mycore.common.MCRMailer

public class MCRMailer
extends Object

This class provides methods to send emails from within a MyCoRe application.

Version:
$Revision: 15111 $ $Date: 2009-04-28 11:50:42 +0200 (Tue, 28 Apr 2009) $
Author:
Marc Schluepmann, Frank Lützenkirchen, Werner Greßhoff

Field Summary
protected static String encoding
           
(package private) static Logger logger
          Logger
protected static javax.mail.Session mailSession
           
protected static int numTries
          How often should MCRMailer try to send mail?
 
Constructor Summary
MCRMailer()
           
 
Method Summary
static void send(Element email)
          Send email from a given XML document.
static void send(String from, List<String> replyTo, List<String> to, List<String> bcc, String subject, String body, List<String> parts)
          Sends email.
static void send(String sender, List<String> recipients, String subject, String body, boolean bcc)
          This method sends a simple plaintext email to more than one recipient.
static void send(String sender, List<String> recipients, String subject, String body, List<String> parts, boolean bcc)
          This method sends a multipart email to more than one recipient.
static void send(String sender, String recipient, String subject, String body)
          This method sends a simple plaintext email with the given parameters.
static void send(String sender, String recipient, String subject, String body, List<String> parts)
          This method sends a multipart email with the given parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

static Logger logger
Logger


mailSession

protected static javax.mail.Session mailSession

encoding

protected static String encoding

numTries

protected static int numTries
How often should MCRMailer try to send mail?

Constructor Detail

MCRMailer

public MCRMailer()
Method Detail

send

public static void send(String sender,
                        String recipient,
                        String subject,
                        String body)
This method sends a simple plaintext email with the given parameters.

Parameters:
sender - the sender of the email
recipient - the recipient of the email
subject - the subject of the email
body - the textbody of the email

send

public static void send(String sender,
                        List<String> recipients,
                        String subject,
                        String body,
                        boolean bcc)
This method sends a simple plaintext email to more than one recipient. If flag BCC is true, the sender will also get the email as BCC recipient.

Parameters:
sender - the sender of the email
recipients - the recipients of the email as a List of Strings
subject - the subject of the email
body - the textbody of the email
bcc - if true, sender will also get a copy as cc recipient

send

public static void send(String sender,
                        String recipient,
                        String subject,
                        String body,
                        List<String> parts)
This method sends a multipart email with the given parameters.

Parameters:
sender - the sender of the email
recipient - the recipient of the email
subject - the subject of the email
parts - a List of URL strings which should be added as parts
body - the textbody of the email

send

public static void send(String sender,
                        List<String> recipients,
                        String subject,
                        String body,
                        List<String> parts,
                        boolean bcc)
This method sends a multipart email to more than one recipient. If flag BCC is true, the sender will also get the email as BCC recipient.

Parameters:
sender - the sender of the email
recipients - the recipients of the email as a List of Strings
subject - the subject of the email
body - the textbody of the email
parts - a List of URL strings which should be added as parts
bcc - if true, sender will also get a copy as bcc recipient

send

public static void send(Element email)
Send email from a given XML document. See the sample mail below: bingo@bongo.com jim.knopf@lummerland.de frau.waas@lummerland.de Grüße aus der Stadt der Drachen Es ist recht bewölkt. Alles Gute, Jim. http://upload.wikimedia.org/wikipedia/de/f/f7/JimKnopf.jpg

Parameters:
email - the email as JDOM element.

send

public static void send(String from,
                        List<String> replyTo,
                        List<String> to,
                        List<String> bcc,
                        String subject,
                        String body,
                        List<String> parts)
Sends email. When sending email fails (for example, outgoing mail server is not responding), sending will be retried after five minutes. This is done up to 10 times.

Parameters:
from - the sender of the email
replyTo - the reply-to addresses as a List of Strings, may be null
to - the recipients of the email as a List of Strings
bcc - the bcc recipients of the email as a List of Strings, may be null
subject - the subject of the email
body - the text of the email
parts - a List of URL strings which should be added as parts, may be null