Class MailSender
- All Implemented Interfaces:
FrankElement,HasApplicationContext,HasName,HasPhysicalDestination,IConfigurable,IScopeProvider,ISender,ISenderWithParameters,IWithParameters,NameAware,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware,org.springframework.context.Lifecycle
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 ClassesNested 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, paramListFields inherited from class org.frankframework.senders.AbstractSender
log -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidConfigure this component.protected MailSender.MailSessionprotected jakarta.mail.SessionCreate the session during runtimevoidsendEmail(AbstractMailSender.MailSessionBase mailSession) voidsetSmtpHost(String newSmtpHost) Name of the SMTP-host by which the messages are to be sendvoidsetSmtpPort(int newSmtpPort) Port of the SMTP-host by which the messages are to be sendvoidstart()Create a session to validate connectivityMethods inherited from class org.frankframework.senders.AbstractMailSender
extract, isSynchronous, sendMessage, setAuthAlias, setBounceAddress, setDefaultAttachmentName, setDefaultFrom, setDefaultMessageBase64, setDefaultMessageType, setDefaultSubject, setDomainWhitelist, setPassword, setTimeout, setUserIdMethods inherited from class org.frankframework.senders.AbstractSenderWithParameters
addParameter, checkStringAttributeOrParameter, consumesSessionVariable, getParameterList, getParameterOverriddenAttributeValue, getParameterOverriddenAttributeValue, getParameterValueListMethods inherited from class org.frankframework.senders.AbstractSender
createBean, getLogPrefix, getName, isRunning, setApplicationContext, setName, stopMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.ApplicationContextAware
setApplicationContextMethods inherited from interface org.frankframework.core.FrankElement
addConfigWarningMethods inherited from interface org.frankframework.core.HasApplicationContext
getApplicationContext, getConfigurationClassLoaderMethods inherited from interface org.frankframework.core.ISender
sendMessageOrThrow, stop
-
Constructor Details
-
MailSender
public MailSender()
-
-
Method Details
-
configure
Description copied from interface:IConfigurableConfigure this component.configure()is called once at startup of the framework in the configure method of the owner of thisIConfigurable. Purpose of this method is to check whether the static configuration of the object is correct. As much as possible class-instantiating should take place in theconfigure(), to improve performance.In the case of a container, this will propagate the configure signal to all components that apply.
- Specified by:
configurein interfaceIConfigurable- Overrides:
configurein classAbstractMailSender- Throws:
ConfigurationException- in case it was not able to configure the component.
-
start
public void start()Create a session to validate connectivity- Specified by:
startin interfaceISender- Specified by:
startin interfaceorg.springframework.context.Lifecycle- Overrides:
startin classAbstractSender
-
createSession
protected jakarta.mail.Session createSession()Create the session during runtime -
sendEmail
- Specified by:
sendEmailin classAbstractMailSender- Throws:
SenderException
-
createMailSession
- Specified by:
createMailSessionin 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:
getPhysicalDestinationNamein interfaceHasPhysicalDestination
-