Class MailSender
- All Implemented Interfaces:
HasPhysicalDestination
,IConfigurable
,IConfigurationAware
,INamedObject
,IScopeProvider
,ISender
,ISenderWithParameters
,IWithParameters
,org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
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:
- sessionKey
- url
- value of the attachment element
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
- Author:
- Johan Verrips, Gerrit van Brakel
-
Nested Class Summary
Nested classes/interfaces inherited from class org.frankframework.senders.AbstractMailSender
AbstractMailSender.EMail, AbstractMailSender.MailAttachmentBase<T>, AbstractMailSender.MailAttachmentStream, AbstractMailSender.MailSessionBase
-
Field Summary
Fields inherited from class org.frankframework.senders.AbstractSenderWithParameters
parameterNamesMustBeUnique, paramList
Fields inherited from class org.frankframework.senders.AbstractSender
log
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
configure()
is called once at startup of the framework in the configure method of the owner of this sender.protected MailSender.MailSession
protected jakarta.mail.Session
Create the session during runtimeint
void
sendEmail
(AbstractMailSender.MailSessionBase mailSession) void
setSmtpHost
(String newSmtpHost) Name of the SMTP-host by which the messages are to be sendvoid
setSmtpPort
(int newSmtpPort) Port of the SMTP-host by which the messages are to be sendvoid
setUseSsl
(boolean useSsl) When set to true, we ensure TLS is being usedvoid
start()
Create a session to validate connectivityMethods inherited from class org.frankframework.senders.AbstractMailSender
extract, getAuthAlias, getBounceAddress, getCredentialFactory, getDefaultAttachmentName, getDefaultFrom, getDefaultMessageType, getDefaultSubject, getDomainWhitelist, getPassword, getTimeout, getUserId, isDefaultMessageBase64, isSynchronous, sendMessage, setAuthAlias, setBounceAddress, setDefaultAttachmentName, setDefaultFrom, setDefaultMessageBase64, setDefaultMessageType, setDefaultSubject, setDomainWhitelist, setPassword, setTimeout, setUserId
Methods inherited from class org.frankframework.senders.AbstractSenderWithParameters
addParameter, checkStringAttributeOrParameter, consumesSessionVariable, getParameterList, getParameterOverriddenAttributeValue, getParameterOverriddenAttributeValue, getParameterValueList
Methods inherited from class org.frankframework.senders.AbstractSender
createBean, getApplicationContext, getConfigurationClassLoader, getLogPrefix, getName, setApplicationContext, setName, stop
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.context.ApplicationContextAware
setApplicationContext
Methods inherited from interface org.frankframework.core.IConfigurationAware
getApplicationContext, getName
Methods inherited from interface org.frankframework.core.INamedObject
getName, setName
Methods inherited from interface org.frankframework.core.IScopeProvider
getConfigurationClassLoader
Methods inherited from interface org.frankframework.core.ISender
sendMessageOrThrow, stop
-
Constructor Details
-
MailSender
public MailSender()
-
-
Method Details
-
configure
Description copied from interface: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 theconfigure()
oropen()
method, to improve performance.- Specified by:
configure
in interfaceIConfigurable
- Specified by:
configure
in interfaceISender
- Overrides:
configure
in classAbstractMailSender
- Throws:
ConfigurationException
-
start
public void start()Create a session to validate connectivity- Specified by:
start
in interfaceISender
- Overrides:
start
in classAbstractSender
-
createSession
protected jakarta.mail.Session createSession()Create the session during runtime -
sendEmail
- Specified by:
sendEmail
in classAbstractMailSender
- Throws:
SenderException
-
createMailSession
- Specified by:
createMailSession
in classAbstractMailSender
- Throws:
SenderException
-
setSmtpHost
Name of the SMTP-host by which the messages are to be send -
setSmtpPort
public void setSmtpPort(int newSmtpPort) Port of the SMTP-host by which the messages are to be send- Default value
- 25
-
getPhysicalDestinationName
- Specified by:
getPhysicalDestinationName
in interfaceHasPhysicalDestination
-
getDomain
- Specified by:
getDomain
in interfaceHasPhysicalDestination
-
getSmtpHost
-
getSmtpPort
public int getSmtpPort() -
setUseSsl
public void setUseSsl(boolean useSsl) When set to true, we ensure TLS is being used- Default value
- false
-
getProperties
-