@Category(value="Advanced") public class MailSender extends MailSenderBase
sender
that sends a mail specified by an XML message.
Sample email.xml:
<email>
<recipients>
<recipient type="to">***@hotmail.com</recipient>
<recipient type="cc">***@gmail.com</recipient>
</recipients>
<from name="*** ***">***@yahoo.com</from>
<subject>This is the subject</subject>
<threadTopic>subject</threadTopic>
<message>This is the message</message>
<messageType>text/plain</messageType><!-- Optional -->
<messageBase64>false</messageBase64><!-- Optional -->
<charset>UTF-8</charset><!-- Optional -->
<attachments>
<attachment name="filename1.txt">This is the first attachment</attachment>
<attachment name="filename2.pdf" base64="true">JVBERi0xLjQKCjIgMCBvYmoKPDwvVHlwZS9YT2JqZWN0L1N1YnR5cGUvSW1...vSW5mbyA5IDAgUgo+PgpzdGFydHhyZWYKMzQxNDY2CiUlRU9GCg==</attachment>
<attachment name="filename3.pdf" url="file:/c:/filename3.pdf"/>
<attachment name="filename4.pdf" sessionKey="fileContent"/>
</attachments><!-- Optional -->
</email>
Notice: the XML message must be valid XML. Therefore, especially the message element
must be plain text or be wrapped as CDATA. Example:
<message><![CDATA[<h1>This is a HtmlMessage</h1>]]></message>
The sessionKey
attribute for attachment can contain an inputstream or a string. Other types are not supported at this moment.
The attribute order for attachments is as follows:
The base64
attribute is only used when the value of the PipeLineSession variable sessionKey
is a String object
or when the value of the attachment element is used. If base64=true
then the value will be decoded before it's used.
Compilation and Deployment Note: mail.jar (v1.2) and activation.jar must appear BEFORE j2ee.jar.
Otherwise errors like the following might occur: NoClassDefFoundException: com/sun/mail/util/MailDateFormat
Modifier and Type | Class and Description |
---|---|
class |
MailSender.MailSession |
MailSenderBase.EMail, MailSenderBase.MailAttachmentBase<T>, MailSenderBase.MailAttachmentStream, MailSenderBase.MailSessionBase
parameterNamesMustBeUnique, paramList
log
Constructor and Description |
---|
MailSender() |
Modifier and Type | Method and Description |
---|---|
void |
configure()
configure() is called once at startup of the framework in the configure method of the owner of this sender. |
protected MailSender.MailSession |
createMailSession() |
protected jakarta.mail.Session |
createSession()
Create the session during runtime
|
void |
open()
Create a session to validate connectivity
|
String |
sendEmail(MailSenderBase.MailSessionBase mailSession) |
void |
setProperties(Properties properties) |
void |
setSmtpHost(String newSmtpHost)
Name of the SMTP-host by which the messages are to be send
|
void |
setSmtpPort(int newSmtpPort)
Port of the SMTP-host by which the messages are to be send
|
extract, isSynchronous, sendMessage, setAuthAlias, setBounceAddress, setDefaultAttachmentName, setDefaultFrom, setDefaultMessageBase64, setDefaultMessageType, setDefaultSubject, setDomainWhitelist, setPassword, setSmtpAuthAlias, setSmtpPassword, setSmtpUserid, setTimeout, setUserId
addParameter, checkStringAttributeOrParameter, consumesSessionVariable, getParameterList, getParameterOverriddenAttributeValue, getParameterOverriddenAttributeValue, getParameterValueList
close, createBean, getLogPrefix, getName, setApplicationContext, setName
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close, sendMessageOrThrow
getName, setName
getApplicationContext, getName
getConfigurationClassLoader
public void configure() throws ConfigurationException
ISender
configure()
is called once at startup of the framework in the configure method of the owner of this sender.
Purpose of this method is to check whether the static configuration of the sender is correct.
As much as possible class-instantiating should take place in the configure()
or open()
method, to improve performance.configure
in interface IConfigurable
configure
in interface ISender
configure
in class MailSenderBase
ConfigurationException
public void open() throws SenderException
open
in interface ISender
open
in class SenderBase
SenderException
protected jakarta.mail.Session createSession() throws SenderException
SenderException
public String sendEmail(MailSenderBase.MailSessionBase mailSession) throws SenderException
sendEmail
in class MailSenderBase
SenderException
protected MailSender.MailSession createMailSession() throws SenderException
createMailSession
in class MailSenderBase
SenderException
public void setSmtpHost(String newSmtpHost)
public void setSmtpPort(int newSmtpPort)
public void setProperties(Properties properties)
Copyright © 2023 Frank!Framework. All rights reserved.