Class MailSenderImp

java.lang.Object
com.adaptris.mail.MailSenderImp
All Implemented Interfaces:
MailSender
Direct Known Subclasses:
SmtpClient

public abstract class MailSenderImp extends Object implements MailSender
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected javax.mail.internet.MimeMessage
     
    protected javax.mail.Session
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addAttachment(byte[] bytes, String filename, String type)
    Add an attachment to the email.
    void
    addAttachment(byte[] bytes, String filename, String type, String encoding)
    Add an attachment to the email.
    void
    Add an attachment to the email.
    void
    Add a name to the BCC list.
    void
    addBlindCarbonCopy(javax.mail.internet.InternetAddress[] address)
    Add some names to the BCC list.
    void
    Add some names to the CC list.
    void
    addCarbonCopy(javax.mail.internet.InternetAddress[] address)
    Add some names to the CC list.
    void
    Add a header to the mail header.
    void
    Add a property to the set of properties used by the Session.
    void
    addTo(String address)
    Add some names to the TO list.
    void
    addTo(javax.mail.internet.InternetAddress[] address)
    Add some names to the TO list.
    protected void
    Build the content of the MimeMessage from the constituent parts.
    void
    Create a new message Must be called prior to setting recipient list, mail body etc.
    void
    Remove a mail header.
    void
    Remove a property from the set of properties used by the Session.
    void
    Set the encoding type to use for the message type.
    void
    Set the sender.
    void
    setFrom(javax.mail.internet.InternetAddress from)
    Set the sender.
    void
    setMessage(byte[] bytes)
    Set the message
    void
    setMessage(byte[] bytes, String contentType)
    Set the message and content type Content type maybe an arbitary string such as application/edi-x12, although if an appropriate DataContentHandler is not installed, then the results can be undefined.
    void
    Set the subject of the email.
    void
    Start session based on session properties This may be used to initialise the client prior to sending any mail

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.adaptris.mail.MailSender

    send
  • Field Details

    • session

      protected javax.mail.Session session
    • message

      protected javax.mail.internet.MimeMessage message
  • Constructor Details

    • MailSenderImp

      protected MailSenderImp()
  • Method Details

    • addSessionProperty

      public void addSessionProperty(String key, String value)
      Add a property to the set of properties used by the Session.
      Specified by:
      addSessionProperty in interface MailSender
      Parameters:
      key - the key
      value - the value.
    • removeSessionProperty

      public void removeSessionProperty(String key)
      Remove a property from the set of properties used by the Session.
      Specified by:
      removeSessionProperty in interface MailSender
      Parameters:
      key -
    • startSession

      public void startSession() throws MailException
      Description copied from interface: MailSender
      Start session based on session properties This may be used to initialise the client prior to sending any mail
      Specified by:
      startSession in interface MailSender
      Throws:
      MailException
    • newMessage

      public void newMessage() throws MailException
      Description copied from interface: MailSender
      Create a new message Must be called prior to setting recipient list, mail body etc.
      Specified by:
      newMessage in interface MailSender
      Throws:
      MailException
    • addMailHeader

      public void addMailHeader(String key, String value) throws MailException
      Description copied from interface: MailSender
      Add a header to the mail header.
      Specified by:
      addMailHeader in interface MailSender
      Parameters:
      key - the key
      value - the value.
      Throws:
      MailException
    • removeMailHeader

      public void removeMailHeader(String key) throws MailException
      Remove a mail header.
      Specified by:
      removeMailHeader in interface MailSender
      Parameters:
      key -
      Throws:
      MailException
    • addTo

      public void addTo(javax.mail.internet.InternetAddress[] address) throws MailException
      Description copied from interface: MailSender
      Add some names to the TO list.
      Specified by:
      addTo in interface MailSender
      Parameters:
      address - an array of InternetAddress[] representing email addresses
      Throws:
      MailException - if the addresses could not be parsed.
    • addTo

      public void addTo(String address) throws MailException
      Description copied from interface: MailSender
      Add some names to the TO list.
      Specified by:
      addTo in interface MailSender
      Parameters:
      address - the email address name@company.com
      Throws:
      MailException - if the addresses could not be parsed.
    • addCarbonCopy

      public void addCarbonCopy(javax.mail.internet.InternetAddress[] address) throws MailException
      Description copied from interface: MailSender
      Add some names to the CC list.
      Specified by:
      addCarbonCopy in interface MailSender
      Parameters:
      address - an array of InternetAddress[] representing email addresses
      Throws:
      MailException - if the addresses could not be parsed.
    • addCarbonCopy

      public void addCarbonCopy(String address) throws MailException
      Description copied from interface: MailSender
      Add some names to the CC list.
      Specified by:
      addCarbonCopy in interface MailSender
      Parameters:
      address - the email address name@company.com
      Throws:
      MailException - if the addresses could not be parsed.
    • addBlindCarbonCopy

      public void addBlindCarbonCopy(javax.mail.internet.InternetAddress[] address) throws MailException
      Description copied from interface: MailSender
      Add some names to the BCC list.
      Specified by:
      addBlindCarbonCopy in interface MailSender
      Parameters:
      address - an array of InternetAddress[] representing email addresses
      Throws:
      MailException - if the addresses could not be parsed.
    • addBlindCarbonCopy

      public void addBlindCarbonCopy(String address) throws MailException
      Description copied from interface: MailSender
      Add a name to the BCC list.
      Specified by:
      addBlindCarbonCopy in interface MailSender
      Parameters:
      address - email address name@company.com
      Throws:
      MailException - if the addresses could not be parsed.
    • setFrom

      public void setFrom(String from) throws MailException
      Description copied from interface: MailSender
      Set the sender.
      Specified by:
      setFrom in interface MailSender
      Parameters:
      from - email address name@company.com
      Throws:
      MailException - if the addresses could not be parsed.
    • setFrom

      public void setFrom(javax.mail.internet.InternetAddress from) throws MailException
      Description copied from interface: MailSender
      Set the sender.
      Specified by:
      setFrom in interface MailSender
      Parameters:
      from - InternetAddress container for name@company.com
      Throws:
      MailException - if the addresses could not be parsed.
    • setSubject

      public void setSubject(String s) throws MailException
      Description copied from interface: MailSender
      Set the subject of the email.
      Specified by:
      setSubject in interface MailSender
      Parameters:
      s - the subject.
      Throws:
      MailException
    • addAttachment

      public void addAttachment(byte[] bytes, String filename, String type, String encoding) throws MailException
      Description copied from interface: MailSender
      Add an attachment to the email.
      Specified by:
      addAttachment in interface MailSender
      Parameters:
      bytes - the attachment;
      filename - the filename to use for the attachment.
      type - the content type to associate with this attachment
      encoding - of the mime body part for this attachment
      Throws:
      MailException
    • addAttachment

      public void addAttachment(byte[] bytes, String filename, String type) throws MailException
      Description copied from interface: MailSender
      Add an attachment to the email.
      Specified by:
      addAttachment in interface MailSender
      Parameters:
      bytes - the attachment;
      filename - the filename to use for the attachment.
      type - the content type to associate with this attachment
      Throws:
      MailException
    • addAttachment

      public void addAttachment(Attachment a) throws MailException
      Description copied from interface: MailSender
      Add an attachment to the email.
      Specified by:
      addAttachment in interface MailSender
      Parameters:
      a - object;
      Throws:
      MailException
    • setMessage

      public void setMessage(byte[] bytes) throws MailException
      Description copied from interface: MailSender
      Set the message
      Specified by:
      setMessage in interface MailSender
      Parameters:
      bytes - the message;
      Throws:
      MailException
    • setMessage

      public void setMessage(byte[] bytes, String contentType) throws MailException
      Description copied from interface: MailSender
      Set the message and content type Content type maybe an arbitary string such as application/edi-x12, although if an appropriate DataContentHandler is not installed, then the results can be undefined.
      Specified by:
      setMessage in interface MailSender
      Parameters:
      bytes - the message
      contentType - the content type.
      Throws:
      MailException
      See Also:
      • DataContentHandler
    • setEncoding

      public void setEncoding(String enc)
      Description copied from interface: MailSender
      Set the encoding type to use for the message type.

      Valid types of encoding are those defined in RFC2045. They include "base64", "quoted-printable", "7bit", "8bit" and "binary". In addition, "uuencode" is also supported.

      Specified by:
      setEncoding in interface MailSender
      Parameters:
      enc - the encoding type to use.
    • buildContent

      protected void buildContent() throws MailException
      Build the content of the MimeMessage from the constituent parts.
      Throws:
      MailException