Class SimpleMessageBuilder
- java.lang.Object
-
- org.apache.sling.commons.messaging.mail.internal.SimpleMessageBuilder
-
- All Implemented Interfaces:
MessageBuilder
public final class SimpleMessageBuilder extends Object implements MessageBuilder
Builder for MIME messages.
The message builder is using theSessionformSimpleMailServiceand the standard charsetUTF-8.- See Also:
MimeMessage
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull MessageBuilderattachment(byte @NotNull [] content, @NotNull String type, @NotNull String filename)Attaches the given content to the message.@NotNull MessageBuilderattachment(byte @NotNull [] content, @NotNull String type, @NotNull String filename, @Nullable Collection<jakarta.mail.Header> headers)Attaches the given content with headers to the message.@NotNull MessageBuilderbcc(@NotNull jakarta.mail.internet.InternetAddress bcc)Adds the given address to the list of blind carbon copy (bcc) recipients.@NotNull MessageBuilderbcc(@NotNull jakarta.mail.internet.InternetAddress[] addresses)Adds the given addresses to the list of blind carbon copy (bcc) recipients.@NotNull MessageBuilderbcc(@NotNull String address)Creates a newInternetAddressfrom given address and adds it to the list of blind carbon copy (bcc) recipients.@NotNull MessageBuilderbcc(@NotNull String[] addresses)Creates newInternetAddresses from given addresses and adds them to the list of blind carbon copy (bcc) recipients.@NotNull MessageBuilderbcc(@NotNull String address, String name)Creates a newInternetAddressfrom given address and name and adds it to the list of blind carbon copy (bcc) recipients.@NotNull MessageBuilderbcc(@NotNull Collection<String> addresses)Creates newInternetAddresses from given addresses and adds them to the list of blind carbon copy (bcc) recipients.@NotNull jakarta.mail.internet.MimeMessagebuild()Builds the MIME message with the given input.@NotNull MessageBuildercc(@NotNull jakarta.mail.internet.InternetAddress cc)Adds the given address to the list of carbon copy (cc) recipients.@NotNull MessageBuildercc(@NotNull jakarta.mail.internet.InternetAddress[] addresses)Adds the given addresses to the list of carbon copy (cc) recipients.@NotNull MessageBuildercc(@NotNull String address)Creates a newInternetAddressfrom given address and adds it to the list of carbon copy (cc) recipients.@NotNull MessageBuildercc(@NotNull String[] addresses)Creates newInternetAddresses from given addresses and adds them to the list of carbon copy (cc) recipients.@NotNull MessageBuildercc(@NotNull String address, @NotNull String name)Creates a newInternetAddressfrom given address and name and adds it to the list of carbon copy (cc) recipients.@NotNull MessageBuildercc(@NotNull Collection<String> addresses)Creates newInternetAddresses from given addresses and adds them to the list of carbon copy (cc) recipients.@NotNull MessageBuilderfrom(@NotNull jakarta.mail.internet.InternetAddress from)Sets the given address for the RFC 822Fromheader field.@NotNull MessageBuilderfrom(@NotNull String address)Creates a newInternetAddressfrom given address and sets it for the RFC 822Fromheader field.@NotNull MessageBuilderfrom(@NotNull String address, @NotNull String name)Creates a newInternetAddressfrom given address and name and sets it for the RFC 822Fromheader field.@NotNull MessageBuilderheader(@NotNull String name, @Nullable String value)Creates a new header from given name and value and adds it to the list of headers.@NotNull MessageBuilderheaders(@NotNull Collection<jakarta.mail.Header> headers)Adds the given headers to the list of headers.@NotNull MessageBuilderhtml(@NotNull String html)Sets the HTML content.@NotNull MessageBuilderinline(byte @NotNull [] content, @NotNull String type, @NotNull String cid)Inlines the given content into the message.@NotNull MessageBuilderinline(byte @NotNull [] content, @NotNull String type, @NotNull String cid, @Nullable Collection<jakarta.mail.Header> headers)Inlines the given content with headers into the message.@NotNull MessageBuilderreplyTo(@NotNull jakarta.mail.internet.InternetAddress replyTo)Adds the given address to the list of addresses for the RFC 822Reply-Toheader field.@NotNull MessageBuilderreplyTo(@NotNull jakarta.mail.internet.InternetAddress[] addresses)Adds the given addresses to the list of addresses for the RFC 822Reply-Toheader field.@NotNull MessageBuilderreplyTo(@NotNull String address)Creates a newInternetAddressfrom given address and adds it to the list of addresses for the RFC 822Reply-Toheader field.@NotNull MessageBuilderreplyTo(@NotNull String[] addresses)Creates newInternetAddresses from given addresses and adds them to the list of addresses for the RFC 822Reply-Toheader field.@NotNull MessageBuilderreplyTo(@NotNull String address, @NotNull String name)Creates a newInternetAddressfrom given address and name and adds it to the list of addresses for the RFC 822Reply-Toheader field.@NotNull MessageBuilderreplyTo(@NotNull Collection<String> addresses)Creates newInternetAddresses from given addresses and adds them to the list of addresses for the RFC 822Reply-Toheader field.@NotNull MessageBuildersubject(@NotNull String subject)Sets the given subject into theSubjectheader field.@NotNull MessageBuildertext(@NotNull String text)Sets the plain text content.@NotNull MessageBuilderto(@NotNull jakarta.mail.internet.InternetAddress to)Adds the given address to the list of primary (to) recipients.@NotNull MessageBuilderto(@NotNull jakarta.mail.internet.InternetAddress[] addresses)Adds the given addresses to the list of primary (to) recipients.@NotNull MessageBuilderto(@NotNull String address)Creates a newInternetAddressfrom given address and adds it to the list of primary (to) recipients.@NotNull MessageBuilderto(@NotNull String[] addresses)Creates newInternetAddresses from given addresses and adds them to the list of primary (to) recipients.@NotNull MessageBuilderto(@NotNull String address, @NotNull String name)Creates a newInternetAddressfrom given address and name and adds it to the list of primary (to) recipients.@NotNull MessageBuilderto(@NotNull Collection<String> addresses)Creates newInternetAddresses from given addresses and adds them to the list of primary (to) recipients.
-
-
-
Method Detail
-
header
@NotNull public @NotNull MessageBuilder header(@NotNull @NotNull String name, @Nullable @Nullable String value)
Description copied from interface:MessageBuilderCreates a new header from given name and value and adds it to the list of headers.- Specified by:
headerin interfaceMessageBuilder- Parameters:
name- the name of the headervalue- the value of the header- Returns:
- the message builder
- See Also:
Header,InternetHeaders
-
headers
@NotNull public @NotNull MessageBuilder headers(@NotNull @NotNull Collection<jakarta.mail.Header> headers)
Description copied from interface:MessageBuilderAdds the given headers to the list of headers.- Specified by:
headersin interfaceMessageBuilder- Parameters:
headers- the headers to add- Returns:
- the message builder
- See Also:
Header,InternetHeaders
-
from
@NotNull public @NotNull MessageBuilder from(@NotNull @NotNull jakarta.mail.internet.InternetAddress from)
Description copied from interface:MessageBuilderSets the given address for the RFC 822Fromheader field.- Specified by:
fromin interfaceMessageBuilder- Parameters:
from- the address- Returns:
- the message builder
- See Also:
MimeMessage.setFrom(Address)
-
from
@NotNull public @NotNull MessageBuilder from(@NotNull @NotNull String address) throws jakarta.mail.internet.AddressException
Description copied from interface:MessageBuilderCreates a newInternetAddressfrom given address and sets it for the RFC 822Fromheader field.- Specified by:
fromin interfaceMessageBuilder- Parameters:
address- the address- Returns:
- the message builder
- Throws:
jakarta.mail.internet.AddressException- if creating anInternetAddressfrom given address string fails- See Also:
MimeMessage.setFrom(Address)
-
from
@NotNull public @NotNull MessageBuilder from(@NotNull @NotNull String address, @NotNull @NotNull String name) throws jakarta.mail.internet.AddressException
Description copied from interface:MessageBuilderCreates a newInternetAddressfrom given address and name and sets it for the RFC 822Fromheader field.- Specified by:
fromin interfaceMessageBuilder- Parameters:
address- the addressname- the (personal) name- Returns:
- the message builder
- Throws:
jakarta.mail.internet.AddressException- if creating anInternetAddressfrom given address string fails- See Also:
MimeMessage.setFrom(Address)
-
to
@NotNull public @NotNull MessageBuilder to(@NotNull @NotNull jakarta.mail.internet.InternetAddress to)
Description copied from interface:MessageBuilderAdds the given address to the list of primary (to) recipients.- Specified by:
toin interfaceMessageBuilder- Parameters:
to- the address- Returns:
- the message builder
- See Also:
MimeMessage.setRecipients(RecipientType, Address[]),Message.RecipientType.TO
-
to
@NotNull public @NotNull MessageBuilder to(@NotNull @NotNull String address) throws jakarta.mail.internet.AddressException
Description copied from interface:MessageBuilderCreates a newInternetAddressfrom given address and adds it to the list of primary (to) recipients.- Specified by:
toin interfaceMessageBuilder- Parameters:
address- the address- Returns:
- the message builder
- Throws:
jakarta.mail.internet.AddressException- if creating anInternetAddressfrom given address string fails- See Also:
MimeMessage.setRecipients(RecipientType, Address[]),Message.RecipientType.TO
-
to
@NotNull public @NotNull MessageBuilder to(@NotNull @NotNull String address, @NotNull @NotNull String name) throws jakarta.mail.internet.AddressException
Description copied from interface:MessageBuilderCreates a newInternetAddressfrom given address and name and adds it to the list of primary (to) recipients.- Specified by:
toin interfaceMessageBuilder- Parameters:
address- the addressname- the (personal) name- Returns:
- the message builder
- Throws:
jakarta.mail.internet.AddressException- if creating anInternetAddressfrom given address string fails- See Also:
MimeMessage.setRecipients(RecipientType, Address[]),Message.RecipientType.TO
-
to
@NotNull public @NotNull MessageBuilder to(@NotNull @NotNull jakarta.mail.internet.InternetAddress[] addresses)
Description copied from interface:MessageBuilderAdds the given addresses to the list of primary (to) recipients.- Specified by:
toin interfaceMessageBuilder- Parameters:
addresses- the addresses- Returns:
- the message builder
- See Also:
MimeMessage.setRecipients(RecipientType, Address[]),Message.RecipientType.TO
-
to
@NotNull public @NotNull MessageBuilder to(@NotNull @NotNull String[] addresses) throws jakarta.mail.internet.AddressException
Description copied from interface:MessageBuilderCreates newInternetAddresses from given addresses and adds them to the list of primary (to) recipients.- Specified by:
toin interfaceMessageBuilder- Parameters:
addresses- the addresses- Returns:
- the message builder
- Throws:
jakarta.mail.internet.AddressException- if creating anInternetAddressfrom given address strings fails- See Also:
MimeMessage.setRecipients(RecipientType, Address[]),Message.RecipientType.TO
-
to
@NotNull public @NotNull MessageBuilder to(@NotNull @NotNull Collection<String> addresses) throws jakarta.mail.internet.AddressException
Description copied from interface:MessageBuilderCreates newInternetAddresses from given addresses and adds them to the list of primary (to) recipients.- Specified by:
toin interfaceMessageBuilder- Parameters:
addresses- the addresses- Returns:
- the message builder
- Throws:
jakarta.mail.internet.AddressException- if creating anInternetAddressfrom given address strings fails- See Also:
MimeMessage.setRecipients(RecipientType, Address[]),Message.RecipientType.TO
-
cc
@NotNull public @NotNull MessageBuilder cc(@NotNull @NotNull jakarta.mail.internet.InternetAddress cc)
Description copied from interface:MessageBuilderAdds the given address to the list of carbon copy (cc) recipients.- Specified by:
ccin interfaceMessageBuilder- Parameters:
cc- the address- Returns:
- the message builder
- See Also:
MimeMessage.setRecipients(RecipientType, Address[]),Message.RecipientType.CC
-
cc
@NotNull public @NotNull MessageBuilder cc(@NotNull @NotNull String address) throws jakarta.mail.internet.AddressException
Description copied from interface:MessageBuilderCreates a newInternetAddressfrom given address and adds it to the list of carbon copy (cc) recipients.- Specified by:
ccin interfaceMessageBuilder- Parameters:
address- the address- Returns:
- the message builder
- Throws:
jakarta.mail.internet.AddressException- if creating anInternetAddressfrom given address string fails- See Also:
MimeMessage.setRecipients(RecipientType, Address[]),Message.RecipientType.CC
-
cc
@NotNull public @NotNull MessageBuilder cc(@NotNull @NotNull String address, @NotNull @NotNull String name) throws jakarta.mail.internet.AddressException
Description copied from interface:MessageBuilderCreates a newInternetAddressfrom given address and name and adds it to the list of carbon copy (cc) recipients.- Specified by:
ccin interfaceMessageBuilder- Parameters:
address- the addressname- the (personal) name- Returns:
- the message builder
- Throws:
jakarta.mail.internet.AddressException- if creating anInternetAddressfrom given address string fails- See Also:
MimeMessage.setRecipients(RecipientType, Address[]),Message.RecipientType.CC
-
cc
@NotNull public @NotNull MessageBuilder cc(@NotNull @NotNull jakarta.mail.internet.InternetAddress[] addresses)
Description copied from interface:MessageBuilderAdds the given addresses to the list of carbon copy (cc) recipients.- Specified by:
ccin interfaceMessageBuilder- Parameters:
addresses- the addresses- Returns:
- the message builder
- See Also:
MimeMessage.setRecipients(RecipientType, Address[]),Message.RecipientType.CC
-
cc
@NotNull public @NotNull MessageBuilder cc(@NotNull @NotNull String[] addresses) throws jakarta.mail.internet.AddressException
Description copied from interface:MessageBuilderCreates newInternetAddresses from given addresses and adds them to the list of carbon copy (cc) recipients.- Specified by:
ccin interfaceMessageBuilder- Parameters:
addresses- the addresses- Returns:
- the message builder
- Throws:
jakarta.mail.internet.AddressException- if creating anInternetAddressfrom given address strings fails- See Also:
MimeMessage.setRecipients(RecipientType, Address[]),Message.RecipientType.CC
-
cc
@NotNull public @NotNull MessageBuilder cc(@NotNull @NotNull Collection<String> addresses) throws jakarta.mail.internet.AddressException
Description copied from interface:MessageBuilderCreates newInternetAddresses from given addresses and adds them to the list of carbon copy (cc) recipients.- Specified by:
ccin interfaceMessageBuilder- Parameters:
addresses- the addresses- Returns:
- the message builder
- Throws:
jakarta.mail.internet.AddressException- if creating anInternetAddressfrom given address strings fails- See Also:
MimeMessage.setRecipients(RecipientType, Address[]),Message.RecipientType.CC
-
bcc
@NotNull public @NotNull MessageBuilder bcc(@NotNull @NotNull jakarta.mail.internet.InternetAddress bcc)
Description copied from interface:MessageBuilderAdds the given address to the list of blind carbon copy (bcc) recipients.- Specified by:
bccin interfaceMessageBuilder- Parameters:
bcc- the address- Returns:
- the message builder
- See Also:
MimeMessage.setRecipients(RecipientType, Address[]),Message.RecipientType.BCC
-
bcc
@NotNull public @NotNull MessageBuilder bcc(@NotNull @NotNull String address) throws jakarta.mail.internet.AddressException
Description copied from interface:MessageBuilderCreates a newInternetAddressfrom given address and adds it to the list of blind carbon copy (bcc) recipients.- Specified by:
bccin interfaceMessageBuilder- Parameters:
address- the address- Returns:
- the message builder
- Throws:
jakarta.mail.internet.AddressException- if creating anInternetAddressfrom given address string fails- See Also:
MimeMessage.setRecipients(RecipientType, Address[]),Message.RecipientType.BCC
-
bcc
@NotNull public @NotNull MessageBuilder bcc(@NotNull @NotNull String address, String name) throws jakarta.mail.internet.AddressException
Description copied from interface:MessageBuilderCreates a newInternetAddressfrom given address and name and adds it to the list of blind carbon copy (bcc) recipients.- Specified by:
bccin interfaceMessageBuilder- Parameters:
address- the addressname- the (personal) name- Returns:
- the message builder
- Throws:
jakarta.mail.internet.AddressException- if creating anInternetAddressfrom given address string fails- See Also:
MimeMessage.setRecipients(RecipientType, Address[]),Message.RecipientType.BCC
-
bcc
@NotNull public @NotNull MessageBuilder bcc(@NotNull @NotNull jakarta.mail.internet.InternetAddress[] addresses)
Description copied from interface:MessageBuilderAdds the given addresses to the list of blind carbon copy (bcc) recipients.- Specified by:
bccin interfaceMessageBuilder- Parameters:
addresses- the addresses- Returns:
- the message builder
- See Also:
MimeMessage.setRecipients(RecipientType, Address[]),Message.RecipientType.BCC
-
bcc
@NotNull public @NotNull MessageBuilder bcc(@NotNull @NotNull String[] addresses) throws jakarta.mail.internet.AddressException
Description copied from interface:MessageBuilderCreates newInternetAddresses from given addresses and adds them to the list of blind carbon copy (bcc) recipients.- Specified by:
bccin interfaceMessageBuilder- Parameters:
addresses- the addresses- Returns:
- the message builder
- Throws:
jakarta.mail.internet.AddressException- if creating anInternetAddressfrom given address strings fails- See Also:
MimeMessage.setRecipients(RecipientType, Address[]),Message.RecipientType.BCC
-
bcc
@NotNull public @NotNull MessageBuilder bcc(@NotNull @NotNull Collection<String> addresses) throws jakarta.mail.internet.AddressException
Description copied from interface:MessageBuilderCreates newInternetAddresses from given addresses and adds them to the list of blind carbon copy (bcc) recipients.- Specified by:
bccin interfaceMessageBuilder- Parameters:
addresses- the addresses- Returns:
- the message builder
- Throws:
jakarta.mail.internet.AddressException- if creating anInternetAddressfrom given address strings fails- See Also:
MimeMessage.setRecipients(RecipientType, Address[]),Message.RecipientType.BCC
-
replyTo
@NotNull public @NotNull MessageBuilder replyTo(@NotNull @NotNull jakarta.mail.internet.InternetAddress replyTo)
Description copied from interface:MessageBuilderAdds the given address to the list of addresses for the RFC 822Reply-Toheader field.- Specified by:
replyToin interfaceMessageBuilder- Parameters:
replyTo- the address- Returns:
- the message builder
- See Also:
MimeMessage.setReplyTo(Address[])
-
replyTo
@NotNull public @NotNull MessageBuilder replyTo(@NotNull @NotNull String address) throws jakarta.mail.internet.AddressException
Description copied from interface:MessageBuilderCreates a newInternetAddressfrom given address and adds it to the list of addresses for the RFC 822Reply-Toheader field.- Specified by:
replyToin interfaceMessageBuilder- Parameters:
address- the address- Returns:
- the message builder
- Throws:
jakarta.mail.internet.AddressException- if creating anInternetAddressfrom given address string fails- See Also:
MimeMessage.setReplyTo(Address[])
-
replyTo
@NotNull public @NotNull MessageBuilder replyTo(@NotNull @NotNull String address, @NotNull @NotNull String name) throws jakarta.mail.internet.AddressException
Description copied from interface:MessageBuilderCreates a newInternetAddressfrom given address and name and adds it to the list of addresses for the RFC 822Reply-Toheader field.- Specified by:
replyToin interfaceMessageBuilder- Parameters:
address- the addressname- the (personal) name- Returns:
- the message builder
- Throws:
jakarta.mail.internet.AddressException- if creating anInternetAddressfrom given address string fails- See Also:
MimeMessage.setReplyTo(Address[])
-
replyTo
@NotNull public @NotNull MessageBuilder replyTo(@NotNull @NotNull jakarta.mail.internet.InternetAddress[] addresses)
Description copied from interface:MessageBuilderAdds the given addresses to the list of addresses for the RFC 822Reply-Toheader field.- Specified by:
replyToin interfaceMessageBuilder- Parameters:
addresses- the addresses- Returns:
- the message builder
- See Also:
MimeMessage.setReplyTo(Address[])
-
replyTo
@NotNull public @NotNull MessageBuilder replyTo(@NotNull @NotNull String[] addresses) throws jakarta.mail.internet.AddressException
Description copied from interface:MessageBuilderCreates newInternetAddresses from given addresses and adds them to the list of addresses for the RFC 822Reply-Toheader field.- Specified by:
replyToin interfaceMessageBuilder- Parameters:
addresses- the addresses- Returns:
- the message builder
- Throws:
jakarta.mail.internet.AddressException- if creating anInternetAddressfrom given address strings fails- See Also:
MimeMessage.setReplyTo(Address[])
-
replyTo
@NotNull public @NotNull MessageBuilder replyTo(@NotNull @NotNull Collection<String> addresses) throws jakarta.mail.internet.AddressException
Description copied from interface:MessageBuilderCreates newInternetAddresses from given addresses and adds them to the list of addresses for the RFC 822Reply-Toheader field.- Specified by:
replyToin interfaceMessageBuilder- Parameters:
addresses- the addresses- Returns:
- the message builder
- Throws:
jakarta.mail.internet.AddressException- if creating anInternetAddressfrom given address strings fails- See Also:
MimeMessage.setReplyTo(Address[])
-
subject
@NotNull public @NotNull MessageBuilder subject(@NotNull @NotNull String subject)
Description copied from interface:MessageBuilderSets the given subject into theSubjectheader field.- Specified by:
subjectin interfaceMessageBuilder- Parameters:
subject- the subject of the message- Returns:
- the message builder
- See Also:
MimeMessage.setSubject(String)
-
text
@NotNull public @NotNull MessageBuilder text(@NotNull @NotNull String text)
Description copied from interface:MessageBuilderSets the plain text content.- Specified by:
textin interfaceMessageBuilder- Parameters:
text- the plain text content- Returns:
- the message builder
- See Also:
MimeMessage.setText(String, String),MimeBodyPart.setContent(Object, String)
-
html
@NotNull public @NotNull MessageBuilder html(@NotNull @NotNull String html)
Description copied from interface:MessageBuilderSets the HTML content.- Specified by:
htmlin interfaceMessageBuilder- Parameters:
html- the HTML content- Returns:
- the message builder
- See Also:
MimeBodyPart.setContent(Object, String)
-
attachment
@NotNull public @NotNull MessageBuilder attachment(byte @NotNull [] content, @NotNull @NotNull String type, @NotNull @NotNull String filename)
Description copied from interface:MessageBuilderAttaches the given content to the message.- Specified by:
attachmentin interfaceMessageBuilder- Parameters:
content- the content to attachtype- the type of the content (content/media/MIME type)filename- the filename of the attachment- Returns:
- the message builder
- See Also:
Part.ATTACHMENT
-
attachment
@NotNull public @NotNull MessageBuilder attachment(byte @NotNull [] content, @NotNull @NotNull String type, @NotNull @NotNull String filename, @Nullable @Nullable Collection<jakarta.mail.Header> headers)
Description copied from interface:MessageBuilderAttaches the given content with headers to the message.- Specified by:
attachmentin interfaceMessageBuilder- Parameters:
content- the content to attachtype- the type of the content (content/media/MIME type)filename- the filename of the attachmentheaders- the headers for the content- Returns:
- the message builder
- See Also:
Part.ATTACHMENT
-
inline
@NotNull public @NotNull MessageBuilder inline(byte @NotNull [] content, @NotNull @NotNull String type, @NotNull @NotNull String cid)
Description copied from interface:MessageBuilderInlines the given content into the message.- Specified by:
inlinein interfaceMessageBuilder- Parameters:
content- the content to inlinetype- the type of the content (content/media/MIME type)cid- the content identifier (Content-ID)- Returns:
- the message builder
- See Also:
Part.INLINE
-
inline
@NotNull public @NotNull MessageBuilder inline(byte @NotNull [] content, @NotNull @NotNull String type, @NotNull @NotNull String cid, @Nullable @Nullable Collection<jakarta.mail.Header> headers)
Description copied from interface:MessageBuilderInlines the given content with headers into the message.- Specified by:
inlinein interfaceMessageBuilder- Parameters:
content- the content to inlinetype- the type of the content (content/media/MIME type)cid- the content identifier (Content-ID)headers- the headers for the content- Returns:
- the message builder
- See Also:
Part.INLINE
-
build
@NotNull public @NotNull jakarta.mail.internet.MimeMessage build() throws jakarta.mail.MessagingExceptionDescription copied from interface:MessageBuilderBuilds the MIME message with the given input.- Specified by:
buildin interfaceMessageBuilder- Returns:
- the built message
- Throws:
jakarta.mail.MessagingException- if building message fails
-
-