public class EmailBuilder extends Object
| Constructor and Description |
|---|
EmailBuilder() |
| Modifier and Type | Method and Description |
|---|---|
EmailBuilder |
addAttachment(String name,
byte[] data,
String mimetype)
Adds an attachment to the email message and generates the necessary
DataSource with the given byte data. |
EmailBuilder |
addAttachment(String name,
DataSource filedata)
Overloaded method which sets an attachment on account of name and
DataSource. |
EmailBuilder |
addHeader(String name,
Object value)
Adds a header to the
headers list. |
EmailBuilder |
bcc(Recipient... recipientsToAdd)
Adds new
Recipient instances to the list on account of name, address with recipient type Message.RecipientType#BCC. |
EmailBuilder |
bcc(String... emailAddresses)
Adds new
Recipient instances to the list on account of empty name, address with recipient type Message.RecipientType#BCC. |
EmailBuilder |
bcc(String emailAddressList)
Delegates to
bcc(String, String) while omitting the name for the BCC recipient(s). |
EmailBuilder |
bcc(String name,
String emailAddressList)
Adds anew
Recipient instances to the list on account of empty name, address with recipient type Message.RecipientType#BCC. |
Email |
build() |
EmailBuilder |
cc(Recipient... recipientsToAdd)
Adds new
Recipient instances to the list on account of name, address with recipient type Message.RecipientType#CC. |
EmailBuilder |
cc(String... emailAddresses)
Adds new
Recipient instances to the list on account of empty name, address with recipient type Message.RecipientType#CC. |
EmailBuilder |
cc(String emailAddressList)
Delegates to
cc(String, String) while omitting the name for the CC recipient(s). |
EmailBuilder |
cc(String name,
String emailAddressList)
Adds anew
Recipient instances to the list on account of empty name, address with recipient type Message.RecipientType#CC. |
EmailBuilder |
embedImage(String name,
byte[] data,
String mimetype)
Adds an embedded image (attachment type) to the email message and generates the necessary
DataSource with the given byte data. |
EmailBuilder |
embedImage(String name,
DataSource imagedata)
Overloaded method which sets an embedded image on account of name and
DataSource. |
EmailBuilder |
from(Recipient recipient)
Sets the sender address
fromRecipient with preconfigured Recipient. |
EmailBuilder |
from(String name,
String fromAddress)
Sets the sender address
fromRecipient. |
List<AttachmentResource> |
getAttachments() |
Recipient |
getDispositionNotificationTo() |
File |
getDkimPrivateKeyFile() |
InputStream |
getDkimPrivateKeyInputStream() |
String |
getDkimSelector() |
List<AttachmentResource> |
getEmbeddedImages() |
Recipient |
getFromRecipient() |
Map<String,String> |
getHeaders() |
String |
getId() |
List<Recipient> |
getRecipients() |
Recipient |
getReplyToRecipient() |
Recipient |
getReturnReceiptTo() |
String |
getSigningDomain() |
String |
getSubject() |
String |
getText() |
String |
getTextHTML() |
EmailBuilder |
id(String id)
Sets the optional id to be used when sending using the underlying Java Mail framework.
|
boolean |
isUseDispositionNotificationTo() |
boolean |
isUseReturnReceiptTo() |
EmailBuilder |
replyTo(Recipient recipient)
Sets
replyToRecipient (optional) with preconfigured Recipient. |
EmailBuilder |
replyTo(String name,
String replyToAddress)
Sets
replyToRecipient (optional). |
EmailBuilder |
signWithDomainKey(byte[] dkimPrivateKey,
String signingDomain,
String dkimSelector)
Sets all info needed for DKIM, using a byte array for private key data.
|
EmailBuilder |
signWithDomainKey(File dkimPrivateKeyFile,
String signingDomain,
String dkimSelector)
Sets all info needed for DKIM, using a file reference for private key data.
|
EmailBuilder |
signWithDomainKey(InputStream dkimPrivateKeyInputStream,
String signingDomain,
String dkimSelector)
Sets all info needed for DKIM, using an input stream for private key data.
|
EmailBuilder |
signWithDomainKey(String dkimPrivateKey,
String signingDomain,
String dkimSelector)
Sets all info needed for DKIM, using a byte array for private key data.
|
EmailBuilder |
subject(String subject)
Sets the
subject. |
EmailBuilder |
text(String text)
Sets the
text. |
EmailBuilder |
textHTML(String textHTML)
Sets the
textHTML. |
EmailBuilder |
to(Recipient... recipientsToAdd)
Adds new
Recipient instances to the list on account of name, address with recipient type Message.RecipientType#TO. |
EmailBuilder |
to(String... emailAddresses)
Adds new
Recipient instances to the list on account of empty name, address with recipient type Message.RecipientType#TO. |
EmailBuilder |
to(String emailAddressList)
Delegates to
to(String, String) while omitting the name used for the recipient(s). |
EmailBuilder |
to(String name,
String emailAddressList)
Adds anew
Recipient instances to the list on account of given name, address with recipient type Message.RecipientType#TO. |
EmailBuilder |
withDispositionNotificationTo()
Indicates that we want to use the NPM flag
dispositionNotificationTo. |
EmailBuilder |
withDispositionNotificationTo(Recipient recipient)
Indicates that we want to use the NPM flag
dispositionNotificationTo with the given preconfigred Recipient. |
EmailBuilder |
withDispositionNotificationTo(String address)
Indicates that we want to use the NPM flag
dispositionNotificationTo with the given mandatory address. |
EmailBuilder |
withDispositionNotificationTo(String name,
String address)
Indicates that we want to use the NPM flag
dispositionNotificationTo with the given optional name and mandatory address. |
EmailBuilder |
withReturnReceiptTo()
Indicates that we want to use the flag
returnReceiptTo. |
EmailBuilder |
withReturnReceiptTo(Recipient recipient)
Indicates that we want to use the NPM flag
returnReceiptTo with the preconfigured Recipient. |
EmailBuilder |
withReturnReceiptTo(String address)
Indicates that we want to use the NPM flag
returnReceiptTo with the given mandatory address. |
EmailBuilder |
withReturnReceiptTo(String name,
String address)
Indicates that we want to use the NPM flag
returnReceiptTo with the given optional name and mandatory address. |
public Email build()
public EmailBuilder id(@Nullable String id)
public EmailBuilder from(@Nullable String name, @Nonnull String fromAddress)
fromRecipient.name - The sender's name.fromAddress - The sender's email address.public EmailBuilder from(@Nonnull Recipient recipient)
fromRecipient with preconfigured Recipient.recipient - Preconfigured recipient (name is optional).public EmailBuilder replyTo(@Nullable String name, @Nonnull String replyToAddress)
replyToRecipient (optional).name - The replied-to-receiver name.replyToAddress - The replied-to-receiver email address.public EmailBuilder replyTo(@Nonnull Recipient recipient)
replyToRecipient (optional) with preconfigured Recipient.recipient - Preconfigured recipient (name is optional).public EmailBuilder subject(@Nonnull String subject)
subject.public EmailBuilder text(@Nullable String text)
text.public EmailBuilder textHTML(@Nullable String textHTML)
textHTML.public EmailBuilder to(@Nonnull Recipient... recipientsToAdd)
Recipient instances to the list on account of name, address with recipient type Message.RecipientType#TO.recipientsToAdd - The recipients whose name and address to userecipients,
Recipientpublic EmailBuilder to(@Nonnull String emailAddressList)
to(String, String) while omitting the name used for the recipient(s).public EmailBuilder to(@Nullable String name, @Nonnull String emailAddressList)
Recipient instances to the list on account of given name, address with recipient type Message.RecipientType#TO.
List can be comma ',' or semicolon ';' separated.name - The name of the recipient(s).emailAddressList - The emailaddresses of the recipients (will be singular in most use cases).recipients,
Recipientpublic EmailBuilder to(@Nonnull String... emailAddresses)
Recipient instances to the list on account of empty name, address with recipient type Message.RecipientType#TO.emailAddresses - The recipients whose address to use for both name and addressrecipients,
Recipientpublic EmailBuilder cc(@Nonnull String... emailAddresses)
Recipient instances to the list on account of empty name, address with recipient type Message.RecipientType#CC.emailAddresses - The recipients whose address to use for both name and addressrecipients,
Recipientpublic EmailBuilder cc(@Nonnull String emailAddressList)
cc(String, String) while omitting the name for the CC recipient(s).public EmailBuilder cc(@Nullable String name, @Nonnull String emailAddressList)
Recipient instances to the list on account of empty name, address with recipient type Message.RecipientType#CC. List can be
comma ',' or semicolon ';' separated.name - The name of the recipient(s).emailAddressList - The recipients whose address to use for both name and addressrecipients,
Recipientpublic EmailBuilder cc(@Nonnull Recipient... recipientsToAdd)
Recipient instances to the list on account of name, address with recipient type Message.RecipientType#CC.recipientsToAdd - The recipients whose name and address to userecipients,
Recipientpublic EmailBuilder bcc(@Nonnull String... emailAddresses)
Recipient instances to the list on account of empty name, address with recipient type Message.RecipientType#BCC.emailAddresses - The recipients whose address to use for both name and addressrecipients,
Recipientpublic EmailBuilder bcc(@Nonnull String emailAddressList)
bcc(String, String) while omitting the name for the BCC recipient(s).public EmailBuilder bcc(@Nullable String name, @Nonnull String emailAddressList)
Recipient instances to the list on account of empty name, address with recipient type Message.RecipientType#BCC. List can be
comma ',' or semicolon ';' separated.name - The name of the recipient(s).emailAddressList - The recipients whose address to use for both name and addressrecipients,
Recipientpublic EmailBuilder bcc(@Nonnull Recipient... recipientsToAdd)
Recipient instances to the list on account of name, address with recipient type Message.RecipientType#BCC.recipientsToAdd - The recipients whose name and address to userecipients,
Recipientpublic EmailBuilder embedImage(@Nonnull String name, @Nonnull byte[] data, @Nonnull String mimetype)
DataSource with the given byte data. Then
delegates to Email.addEmbeddedImage(String, DataSource). At this point the datasource is actually a ByteArrayDataSource.name - The name of the image as being referred to from the message content body (eg. 'signature').data - The byte data of the image to be embedded.mimetype - The content type of the given data (eg. "image/gif" or "image/jpeg").ByteArrayDataSource,
Email.addEmbeddedImage(String, DataSource)public EmailBuilder embedImage(@Nullable String name, @Nonnull DataSource imagedata)
DataSource.name - The name of the image as being referred to from the message content body (eg. 'embeddedimage'). If not provided, the name of the given
data source is used instead.imagedata - The image data.public EmailBuilder addHeader(@Nonnull String name, @Nonnull Object value)
headers list. The value is stored as a String. example: email.addHeader("X-Priority",
2)name - The name of the header.value - The value of the header, which will be stored using String.valueOf(Object).public EmailBuilder addAttachment(@Nullable String name, @Nonnull byte[] data, @Nonnull String mimetype)
DataSource with the given byte data. Then delegates to addAttachment(String, DataSource). At this point the datasource is actually a ByteArrayDataSource.name - The name of the extension (eg. filename including extension).data - The byte data of the attachment.mimetype - The content type of the given data (eg. "plain/text", "image/gif" or "application/pdf").ByteArrayDataSource,
addAttachment(String, DataSource)public EmailBuilder addAttachment(@Nullable String name, @Nonnull DataSource filedata)
DataSource.name - The name of the attachment (eg. 'filename.ext').filedata - The attachment data.public EmailBuilder signWithDomainKey(@Nonnull byte[] dkimPrivateKey, @Nonnull String signingDomain, @Nonnull String dkimSelector)
public EmailBuilder signWithDomainKey(@Nonnull String dkimPrivateKey, @Nonnull String signingDomain, @Nonnull String dkimSelector)
public EmailBuilder signWithDomainKey(@Nonnull File dkimPrivateKeyFile, @Nonnull String signingDomain, @Nonnull String dkimSelector)
public EmailBuilder signWithDomainKey(@Nonnull InputStream dkimPrivateKeyInputStream, @Nonnull String signingDomain, @Nonnull String dkimSelector)
public EmailBuilder withDispositionNotificationTo()
dispositionNotificationTo. The actual address will default to the replyToRecipient
first if set or else fromRecipient.public EmailBuilder withDispositionNotificationTo(@Nonnull String address)
dispositionNotificationTo with the given mandatory address.public EmailBuilder withDispositionNotificationTo(@Nullable String name, @Nonnull String address)
dispositionNotificationTo with the given optional name and mandatory address.public EmailBuilder withDispositionNotificationTo(@Nonnull Recipient recipient)
dispositionNotificationTo with the given preconfigred Recipient.public EmailBuilder withReturnReceiptTo()
returnReceiptTo. The actual address will default to the replyToRecipient
first if set or else fromRecipient.public EmailBuilder withReturnReceiptTo(@Nonnull String address)
returnReceiptTo with the given mandatory address.public EmailBuilder withReturnReceiptTo(@Nullable String name, @Nonnull String address)
returnReceiptTo with the given optional name and mandatory address.public EmailBuilder withReturnReceiptTo(@Nonnull Recipient recipient)
returnReceiptTo with the preconfigured Recipient.public String getId()
public Recipient getFromRecipient()
public Recipient getReplyToRecipient()
public String getText()
public String getTextHTML()
public String getSubject()
public List<AttachmentResource> getEmbeddedImages()
public List<AttachmentResource> getAttachments()
public File getDkimPrivateKeyFile()
public InputStream getDkimPrivateKeyInputStream()
public String getSigningDomain()
public String getDkimSelector()
public boolean isUseDispositionNotificationTo()
public Recipient getDispositionNotificationTo()
public boolean isUseReturnReceiptTo()
public Recipient getReturnReceiptTo()
Copyright © 2017. All rights reserved.