Class MCRMailer

java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
org.mycore.frontend.servlets.MCRServlet
org.mycore.common.MCRMailer
All Implemented Interfaces:
jakarta.servlet.Servlet, jakarta.servlet.ServletConfig, Serializable

public class MCRMailer extends MCRServlet
This class provides methods to send emails from within a MyCoRe application.
Version:
$Revision$ $Date$
Author:
Marc Schluepmann, Frank Lützenkirchen, Werner Greßhoff, René Adler (eagle)
See Also:
  • Field Details

    • ENCODING

      protected static final String ENCODING
    • numTries

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

    • MCRMailer

      public MCRMailer()
  • Method Details

    • doGetPost

      protected void doGetPost(MCRServletJob job) throws Exception
      Description copied from class: MCRServlet
      This method should be overwritten by other servlets. As a default response we indicate the HTTP 1.1 status code 501 (Not Implemented).
      Overrides:
      doGetPost in class MCRServlet
      Throws:
      Exception
    • 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:
       <email>
         <from>bingo@bongo.com</from>
         <to>jim.knopf@lummerland.de</to>
         <bcc>frau.waas@lummerland.de</bcc>
         <subject>Grüße aus der Stadt der Drachen</subject>
         <body>Es ist recht bewölkt. Alles Gute, Jim.</body>
         <body type="html">Es ist recht bewölkt. Alles Gute, Jim.</body>
         <part>http://upload.wikimedia.org/wikipedia/de/f/f7/JimKnopf.jpg</part>
       </email>
       
      Parameters:
      email - the email as JDOM element.
    • send

      public static void send(Element email, Boolean allowException) throws Exception
      Send email from a given XML document. See the sample mail below:
       <email>
         <from>bingo@bongo.com</from>
         <to>jim.knopf@lummerland.de</to>
         <bcc>frau.waas@lummerland.de</bcc>
         <subject>Grüße aus der Stadt der Drachen</subject>
         <body>Es ist recht bewölkt. Alles Gute, Jim.</body>
         <body type="html">Es ist recht bewölkt. Alles Gute, Jim.</body>
         <part>http://upload.wikimedia.org/wikipedia/de/f/f7/JimKnopf.jpg</part>
       </email>
       
      Parameters:
      email - the email as JDOM element.
      allowException - allow to throw exceptions if set to true
      Throws:
      Exception
    • 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
    • send

      public static void send(MCRMailer.EMail mail)
      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:
      mail - the email
    • sendMail

      public static Element sendMail(Document input, String stylesheet, Map<String,String> parameters) throws Exception
      Generates e-mail from the given input document by transforming it with an xsl stylesheet, and sends the e-mail afterwards.
      Parameters:
      input - the xml input document
      stylesheet - the xsl stylesheet that will generate the e-mail, without the ending ".xsl"
      parameters - the optionally empty table of xsl parameters
      Returns:
      the generated e-mail
      Throws:
      Exception
      See Also:
    • sendMail

      public static Element sendMail(Document input, String stylesheet) throws Exception
      Generates e-mail from the given input document by transforming it with an xsl stylesheet, and sends the e-mail afterwards.
      Parameters:
      input - the xml input document
      stylesheet - the xsl stylesheet that will generate the e-mail, without the ending ".xsl"
      Returns:
      the generated e-mail
      Throws:
      Exception
      See Also: