Class MailSenderBase

All Implemented Interfaces:
IConfigurable, IConfigurationAware, INamedObject, IScopeProvider, ISender, ISenderWithParameters, IWithParameters, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware
Direct Known Subclasses:
MailSender, SendGridSender

public abstract class MailSenderBase extends SenderWithParametersBase
Specific parameters
from email address of the sender, subject subject field of the message, threadTopic (optional) conversation field of the message, used to correlate mails in mail viewer (header field "Thread-Topic"). Note: subject must end with value of threadTopic, but cann't be exactly the same, message message itself. If absent, the complete input message is assumed to be the message, messageType message MIME type (at this moment only available are text/plain and text/html - default: text/plain), messageBase64 (boolean) indicates whether the message content is base64 encoded (default: false), charSet the character encoding (e.g. ISO-8859-1 or UTF-8) used to send the email (default: UTF-8), recipients (xml) recipients of the message. Must result in a structure like:
       <recipient type="to">***@hotmail.com</recipient>
       <recipient type="cc">***@gmail.com</recipient>
 
, attachments (xml) attachments to the message. Must result in a structure like:
       <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"/>
 
  • Constructor Details

    • MailSenderBase

      public MailSenderBase()
  • Method Details

    • sendEmail

      protected abstract void sendEmail(MailSenderBase.MailSessionBase mailSession) throws SenderException
      Throws:
      SenderException
    • configure

      public void configure() throws ConfigurationException
      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 the configure() or open() method, to improve performance.
      Specified by:
      configure in interface IConfigurable
      Specified by:
      configure in interface ISender
      Overrides:
      configure in class SenderWithParametersBase
      Throws:
      ConfigurationException
    • sendMessage

      public SenderResult sendMessage(Message message, PipeLineSession session) throws SenderException, TimeoutException
      Description copied from interface: ISender
      Send a message to some destination (as configured in the Sender object). This method may only be called after the configure() method is called.

      The following table shows the difference between synchronous and a-synchronous senders:

       synchronousa-synchronous
      ISender.isSynchronous() returnstruefalse
      return value of sendMessage() isthe reply-messagethe messageId of the message sent
      the correlationID specified with sendMessage()may be ignoredis sent with the message
      a {link TimeOutException}may be thrown if a timeout occurs waiting for a replyshould not be expected

      Multiple objects may try to call this method at the same time, from different threads. Implementations of this method should therefore be thread-safe, or synchronized.

      Throws:
      SenderException
      TimeoutException
    • extract

      Reads fields from either paramList or Xml file
      Throws:
      SenderException
      DomBuilderException
    • createMailSession

      protected abstract MailSenderBase.MailSessionBase createMailSession() throws SenderException
      Throws:
      SenderException
    • isSynchronous

      public boolean isSynchronous()
      Description copied from interface: ISender
      When true, the result of sendMessage is the reply of the request.
    • setAuthAlias

      public void setAuthAlias(String authAlias)
      authAlias used to obtain credentials for authentication
    • setUserId

      public void setUserId(String userId)
      userId on the smtphost
    • setPassword

      public void setPassword(String password)
      password of userid
    • setDefaultSubject

      public void setDefaultSubject(String defaultSubject)
      Set the default value of the subject: header, if not specified in message itself
    • setDefaultFrom

      public void setDefaultFrom(String defaultFrom)
      Set the default from: header, if not specified in message itself
    • setTimeout

      public void setTimeout(int timeout)
      Timeout in milliseconds for socket connection timeout and socket i/o timeouts
      Default value
      20000
    • setDefaultAttachmentName

      public void setDefaultAttachmentName(String defaultAttachmentName)
      When this name is used, it will be followed by a number which is equal to the node's position
      Default value
      attachment
    • setDefaultMessageType

      public void setDefaultMessageType(String defaultMessageType)
      when messageType is not specified defaultMessageType will be used
      Default value
      text/plain
    • setDefaultMessageBase64

      public void setDefaultMessageBase64(boolean defaultMessageBase64)
      when messageBase64 is not specified defaultMessageBase64 will be used
      Default value
      false
    • setBounceAddress

      public void setBounceAddress(String string)
      NDR return address when mail cannot be delivered. This adds a Return-Path header
      Default value
      MAIL FROM attribute
    • setDomainWhitelist

      public void setDomainWhitelist(String domainWhitelist)
      Comma separated list of domains to which mails can be send, domains not on the list are filtered out. Empty allows all domains
    • getAuthAlias

      public String getAuthAlias()
    • getUserId

      public String getUserId()
    • getPassword

      public String getPassword()
    • getCredentialFactory

      public CredentialFactory getCredentialFactory()
    • getDefaultAttachmentName

      public String getDefaultAttachmentName()
    • getDefaultMessageType

      public String getDefaultMessageType()
    • isDefaultMessageBase64

      public boolean isDefaultMessageBase64()
    • getDefaultSubject

      public String getDefaultSubject()
    • getDefaultFrom

      public String getDefaultFrom()
    • getTimeout

      public int getTimeout()
    • getBounceAddress

      public String getBounceAddress()
    • getDomainWhitelist

      public String getDomainWhitelist()