Package org.mycore.common
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
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:
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
protected static int
How often should MCRMailer try to send mail?Fields inherited from class org.mycore.frontend.servlets.MCRServlet
ATTR_MYCORE_SESSION, CURRENT_THREAD_NAME_KEY, INITIAL_SERVLET_NAME_KEY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
doGetPost
(MCRServletJob job) This method should be overwritten by other servlets.static void
This method sends a simple plaintext email with the given parameters.static void
This method sends a multipart email with the given parameters.static void
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 from, List<String> replyTo, List<String> to, List<String> bcc, String subject, String body, List<String> parts) Sends email.static void
Send email from a given XML document.static void
Send email from a given XML document.static void
send
(MCRMailer.EMail mail) Sends email.static Element
Generates e-mail from the given input document by transforming it with an xsl stylesheet, and sends the e-mail afterwards.static Element
Generates e-mail from the given input document by transforming it with an xsl stylesheet, and sends the e-mail afterwards.Methods inherited from class org.mycore.frontend.servlets.MCRServlet
allowCrossDomainRequests, buildRedirectURL, cleanupMCRSession, doGet, doGet, doPost, doPost, getErrorI18N, getLastModified, getLayoutService, getProperty, getReferer, getServletBaseURL, getSession, handleException, init, initializeMCRSession, render, reportException, think, toReferrer, toReferrer
Methods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, service, service
Methods inherited from class jakarta.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
-
Field Details
-
ENCODING
-
numTries
protected static int numTriesHow often should MCRMailer try to send mail?
-
-
Constructor Details
-
MCRMailer
public MCRMailer()
-
-
Method Details
-
doGetPost
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 classMCRServlet
- Throws:
Exception
-
send
This method sends a simple plaintext email with the given parameters.- Parameters:
sender
- the sender of the emailrecipient
- the recipient of the emailsubject
- the subject of the emailbody
- 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 emailrecipients
- the recipients of the email as a List of Stringssubject
- the subject of the emailbody
- the textbody of the emailbcc
- 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 emailrecipient
- the recipient of the emailsubject
- the subject of the emailparts
- a List of URL strings which should be added as partsbody
- 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 emailrecipients
- the recipients of the email as a List of Stringssubject
- the subject of the emailbody
- the textbody of the emailparts
- a List of URL strings which should be added as partsbcc
- if true, sender will also get a copy as bcc recipient
-
send
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
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 totrue
- 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 emailreplyTo
- the reply-to addresses as a List of Strings, may be nullto
- the recipients of the email as a List of Stringsbcc
- the bcc recipients of the email as a List of Strings, may be nullsubject
- the subject of the emailbody
- the text of the emailparts
- a List of URL strings which should be added as parts, may be null
-
send
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 ExceptionGenerates e-mail from the given input document by transforming it with an xsl stylesheet, and sends the e-mail afterwards. -
sendMail
Generates e-mail from the given input document by transforming it with an xsl stylesheet, and sends the e-mail afterwards.
-