Package com.adaptris.mail
Class MailSenderImp
- java.lang.Object
-
- com.adaptris.mail.MailSenderImp
-
- All Implemented Interfaces:
MailSender
- Direct Known Subclasses:
SmtpClient
public abstract class MailSenderImp extends java.lang.Object implements MailSender
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedMailSenderImp()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAttachment(byte[] bytes, java.lang.String filename, java.lang.String type)Add an attachment to the email.voidaddAttachment(byte[] bytes, java.lang.String filename, java.lang.String type, java.lang.String encoding)Add an attachment to the email.voidaddAttachment(Attachment a)Add an attachment to the email.voidaddBlindCarbonCopy(java.lang.String address)Add a name to the BCC list.voidaddBlindCarbonCopy(javax.mail.internet.InternetAddress[] address)Add some names to the BCC list.voidaddCarbonCopy(java.lang.String address)Add some names to the CC list.voidaddCarbonCopy(javax.mail.internet.InternetAddress[] address)Add some names to the CC list.voidaddMailHeader(java.lang.String key, java.lang.String value)Add a header to the mail header.voidaddSessionProperty(java.lang.String key, java.lang.String value)Add a property to the set of properties used by the Session.voidaddTo(java.lang.String address)Add some names to the TO list.voidaddTo(javax.mail.internet.InternetAddress[] address)Add some names to the TO list.protected voidbuildContent()Build the content of the MimeMessage from the constituent parts.voidnewMessage()Create a new message Must be called prior to setting recipient list, mail body etc.voidremoveMailHeader(java.lang.String key)Remove a mail header.voidremoveSessionProperty(java.lang.String key)Remove a property from the set of properties used by the Session.voidsetEncoding(java.lang.String enc)Set the encoding type to use for the message type.voidsetFrom(java.lang.String from)Set the sender.voidsetFrom(javax.mail.internet.InternetAddress from)Set the sender.voidsetMessage(byte[] bytes)Set the messagevoidsetMessage(byte[] bytes, java.lang.String contentType)Set the message and content type Content type maybe an arbitary string such as application/edi-x12, although if an appropriateDataContentHandleris not installed, then the results can be undefined.voidsetSubject(java.lang.String s)Set the subject of the email.voidstartSession()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
-
-
-
-
Method Detail
-
addSessionProperty
public void addSessionProperty(java.lang.String key, java.lang.String value)Add a property to the set of properties used by the Session.- Specified by:
addSessionPropertyin interfaceMailSender- Parameters:
key- the keyvalue- the value.
-
removeSessionProperty
public void removeSessionProperty(java.lang.String key)
Remove a property from the set of properties used by the Session.- Specified by:
removeSessionPropertyin interfaceMailSender- Parameters:
key-
-
startSession
public void startSession() throws MailExceptionDescription copied from interface:MailSenderStart session based on session properties This may be used to initialise the client prior to sending any mail- Specified by:
startSessionin interfaceMailSender- Throws:
MailException
-
newMessage
public void newMessage() throws MailExceptionDescription copied from interface:MailSenderCreate a new message Must be called prior to setting recipient list, mail body etc.- Specified by:
newMessagein interfaceMailSender- Throws:
MailException
-
addMailHeader
public void addMailHeader(java.lang.String key, java.lang.String value) throws MailExceptionDescription copied from interface:MailSenderAdd a header to the mail header.- Specified by:
addMailHeaderin interfaceMailSender- Parameters:
key- the keyvalue- the value.- Throws:
MailException
-
removeMailHeader
public void removeMailHeader(java.lang.String key) throws MailExceptionRemove a mail header.- Specified by:
removeMailHeaderin interfaceMailSender- Parameters:
key-- Throws:
MailException
-
addTo
public void addTo(javax.mail.internet.InternetAddress[] address) throws MailExceptionDescription copied from interface:MailSenderAdd some names to the TO list.- Specified by:
addToin interfaceMailSender- Parameters:
address- an array of InternetAddress[] representing email addresses- Throws:
MailException- if the addresses could not be parsed.
-
addTo
public void addTo(java.lang.String address) throws MailExceptionDescription copied from interface:MailSenderAdd some names to the TO list.- Specified by:
addToin interfaceMailSender- 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 MailExceptionDescription copied from interface:MailSenderAdd some names to the CC list.- Specified by:
addCarbonCopyin interfaceMailSender- Parameters:
address- an array of InternetAddress[] representing email addresses- Throws:
MailException- if the addresses could not be parsed.
-
addCarbonCopy
public void addCarbonCopy(java.lang.String address) throws MailExceptionDescription copied from interface:MailSenderAdd some names to the CC list.- Specified by:
addCarbonCopyin interfaceMailSender- 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 MailExceptionDescription copied from interface:MailSenderAdd some names to the BCC list.- Specified by:
addBlindCarbonCopyin interfaceMailSender- Parameters:
address- an array of InternetAddress[] representing email addresses- Throws:
MailException- if the addresses could not be parsed.
-
addBlindCarbonCopy
public void addBlindCarbonCopy(java.lang.String address) throws MailExceptionDescription copied from interface:MailSenderAdd a name to the BCC list.- Specified by:
addBlindCarbonCopyin interfaceMailSender- Parameters:
address- email address name@company.com- Throws:
MailException- if the addresses could not be parsed.
-
setFrom
public void setFrom(java.lang.String from) throws MailExceptionDescription copied from interface:MailSenderSet the sender.- Specified by:
setFromin interfaceMailSender- 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 MailExceptionDescription copied from interface:MailSenderSet the sender.- Specified by:
setFromin interfaceMailSender- Parameters:
from- InternetAddress container for name@company.com- Throws:
MailException- if the addresses could not be parsed.
-
setSubject
public void setSubject(java.lang.String s) throws MailExceptionDescription copied from interface:MailSenderSet the subject of the email.- Specified by:
setSubjectin interfaceMailSender- Parameters:
s- the subject.- Throws:
MailException
-
addAttachment
public void addAttachment(byte[] bytes, java.lang.String filename, java.lang.String type, java.lang.String encoding) throws MailExceptionDescription copied from interface:MailSenderAdd an attachment to the email.- Specified by:
addAttachmentin interfaceMailSender- Parameters:
bytes- the attachment;filename- the filename to use for the attachment.type- the content type to associate with this attachmentencoding- of the mime body part for this attachment- Throws:
MailException
-
addAttachment
public void addAttachment(byte[] bytes, java.lang.String filename, java.lang.String type) throws MailExceptionDescription copied from interface:MailSenderAdd an attachment to the email.- Specified by:
addAttachmentin interfaceMailSender- 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:MailSenderAdd an attachment to the email.- Specified by:
addAttachmentin interfaceMailSender- Parameters:
a- object;- Throws:
MailException
-
setMessage
public void setMessage(byte[] bytes) throws MailExceptionDescription copied from interface:MailSenderSet the message- Specified by:
setMessagein interfaceMailSender- Parameters:
bytes- the message;- Throws:
MailException
-
setMessage
public void setMessage(byte[] bytes, java.lang.String contentType) throws MailExceptionDescription copied from interface:MailSenderSet the message and content type Content type maybe an arbitary string such as application/edi-x12, although if an appropriateDataContentHandleris not installed, then the results can be undefined.- Specified by:
setMessagein interfaceMailSender- Parameters:
bytes- the messagecontentType- the content type.- Throws:
MailException- See Also:
DataContentHandler
-
setEncoding
public void setEncoding(java.lang.String enc)
Description copied from interface:MailSenderSet 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:
setEncodingin interfaceMailSender- Parameters:
enc- the encoding type to use.
-
buildContent
protected void buildContent() throws MailExceptionBuild the content of the MimeMessage from the constituent parts.- Throws:
MailException
-
-