@Component @Named(value="mailsender") @Singleton public class MailSenderScriptService extends AbstractMailScriptService
Example for sending an HTML message with attachments and a text alternative:
#set ($message = $services.mailSender.createMessage(to, subject))
#set ($discard = $message.addPart("html", "html message", {"alternate" : "text message",
"attachments" : $attachments}))
#set ($mailResult = $services.mailsender.send($message))
componentManagerProvider, execution, mailSender, senderConfiguration, sessionFactory
Constructor and Description |
---|
MailSenderScriptService() |
Modifier and Type | Method and Description |
---|---|
ScriptMimeMessage |
createMessage()
Create an empty Mail message.
|
ScriptMimeMessage |
createMessage(String hint,
Object source)
Creates a pre-filled Mime Message by running the Component implementation of
MimeMessageFactory corresponding to the passed hint. |
ScriptMimeMessage |
createMessage(String hint,
Object source,
Map<String,Object> parameters)
Creates a pre-filled Mime Message by running the Component implementation of
MimeMessageFactory corresponding to the passed hint. |
ScriptMimeMessage |
createMessage(String to,
String subject)
Create a Mail message with the "To" recipient and the mail subject set.
|
ScriptMimeMessage |
createMessage(String from,
String to,
String subject)
Create a Mail message with the "To" recipient and the mail subject set.
|
Iterator<javax.mail.internet.MimeMessage> |
createMessages(String hint,
Object source)
Construct an iterator of Mime Messages by running the Component implementation of
MimeMessageFactory corresponding to the passed hint. |
Iterator<javax.mail.internet.MimeMessage> |
createMessages(String hint,
Object source,
Map<String,Object> parameters)
Construct an iterator of Mime Messages by running the Component implementation of
MimeMessageFactory corresponding to the passed hint. |
MailSenderConfiguration |
getConfiguration() |
protected String |
getErrorKey() |
ScriptMailResult |
send(Iterable<? extends javax.mail.internet.MimeMessage> messages)
Send the list of mails synchronously, using a Memory MailListener} to store the results.
|
ScriptMailResult |
send(Iterable<? extends javax.mail.internet.MimeMessage> messages,
String hint)
Send the mail synchronously (wait till the message is sent).
|
ScriptMailResult |
send(javax.mail.internet.MimeMessage message)
Send one mail synchronously with Memory MailListener .
|
ScriptMailResult |
sendAsynchronously(Iterable<? extends javax.mail.internet.MimeMessage> messages,
String hint)
Send the mail asynchronously.
|
getLastError, sendAsynchronously, setError
public ScriptMimeMessage createMessage(String hint, Object source, Map<String,Object> parameters)
MimeMessageFactory
corresponding to the passed hint.hint
- the component hint of a MimeMessageFactory
componentsource
- the source from which to prefill the Mime Message (depends on the implementation)parameters
- an optional generic list of parameters. The supported parameters depend on the implementationScriptMimeMessage
instancepublic Iterator<javax.mail.internet.MimeMessage> createMessages(String hint, Object source)
MimeMessageFactory
corresponding to the passed hint.hint
- the component hint of a MimeMessageFactory
componentsource
- the source from which to prefill the Mime Messages (depends on the implementation)public Iterator<javax.mail.internet.MimeMessage> createMessages(String hint, Object source, Map<String,Object> parameters)
MimeMessageFactory
corresponding to the passed hint.hint
- the component hint of a MimeMessageFactory
componentsource
- the source from which to prefill the Mime Messages (depends on the implementation)parameters
- an optional generic list of parameters. The supported parameters depend on the implementationpublic ScriptMimeMessage createMessage(String hint, Object source)
MimeMessageFactory
corresponding to the passed hint.hint
- the component hint of a MimeMessageFactory
componentsource
- the source from which to prefill the Mime Message (depends on the implementation)ScriptMimeMessage
instancepublic ScriptMimeMessage createMessage()
public ScriptMimeMessage createMessage(String to, String subject)
to
- the "To" email addresssubject
- the subject of the mail to sendpublic ScriptMimeMessage createMessage(String from, String to, String subject)
from
- the email address of the senderto
- the "To" email addresssubject
- the subject of the mail to sendpublic ScriptMailResult send(javax.mail.internet.MimeMessage message)
message
- the message that was tried to be sentpublic ScriptMailResult send(Iterable<? extends javax.mail.internet.MimeMessage> messages)
messages
- the list of messages to sendpublic ScriptMailResult send(Iterable<? extends javax.mail.internet.MimeMessage> messages, String hint)
ScriptMailResult
.messages
- the list of messages to sendhint
- the component hint of a MailListener
componentpublic ScriptMailResult sendAsynchronously(Iterable<? extends javax.mail.internet.MimeMessage> messages, String hint)
messages
- the list of messages that was tried to be senthint
- the component hint of a MailListener
componentpublic MailSenderConfiguration getConfiguration()
protected String getErrorKey()
getErrorKey
in class AbstractMailScriptService
Copyright © 2004–2019 XWiki. All rights reserved.