Package io.mangoo.email
Class Mail
java.lang.Object
io.mangoo.email.Mail
- Author:
- svenkubiak
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionattachment(Path path) Adds a file as attachment to the mailattachments(List<Path> paths) Adds a list of files as attachment to the mailSets one or more BCC addressSets one or more CC addressSets the FROM addressSets the FROM address and namebooleanAdds a header valuehtmlMessage(String message) Adds html message text.htmlMessage(String template, Map<String, Object> content) Adds html message text which uses a given template and content to renderbooleanstatic MailnewMail()Creates a new mail instancepriority(int priority) Sets the email prioritySets REPLY-TO addressvoidsend()Sends the mailSets message subject with specified encoding to override default platform encoding.textMessage(String message) Adds plain message texttextMessage(String template, Map<String, Object> content) Adds plain message text which uses a given template and content to renderSets one or more TO address
-
Constructor Details
-
Mail
public Mail()
-
-
Method Details
-
newMail
Creates a new mail instance- Returns:
- A mail object instance
-
to
Sets one or more TO address- Parameters:
tos- Address may be specified with personal name like this:Jenny Doe <email@foo.com>.- Returns:
- A mail object instance
-
cc
Sets one or more CC address- Parameters:
ccs- array ofStrings to set.- Returns:
- A mail object instance
-
bcc
Sets one or more BCC address- Parameters:
bccs- array ofStrings to set.- Returns:
- A mail object instance
-
subject
Sets message subject with specified encoding to override default platform encoding. The application must ensure that the subject does not contain any line breaks.- Parameters:
subject- The message subject- Returns:
- A mail object instance
-
from
Sets the FROM address and name- Parameters:
fromName- The name of the sender e.g. Peter ParkerfromAddress- Address may be specified with personal name like this:email@foo.com- Returns:
- A mail object instance
-
from
Sets the FROM address- Parameters:
fromAddress- Address may be specified with personal name like this:email@foo.com- Returns:
- A mail object instance
-
header
Adds a header value- Parameters:
name- The name of the headervalue- The value of the header- Returns:
- A mail object instance
-
replyTo
Sets REPLY-TO address- Parameters:
replyTo- Address may be specified with personal name like this:Jenny Doe <email@foo.com>- Returns:
- A mail object instance
-
priority
Sets the email priority- Parameters:
priority- - 1 being the highest priority, 3 = normal priority and 5 = lowest priority- Returns:
- A mail object instance
-
attachment
Adds a file as attachment to the mail- Parameters:
path- The Path to attach- Returns:
- A mail object instance
-
attachments
Adds a list of files as attachment to the mail- Parameters:
paths- The Path files to attach- Returns:
- A mail object instance
-
textMessage
Adds plain message text- Parameters:
message- The text to add as aString.- Returns:
- A mail object instance
-
htmlMessage
Adds html message text.- Parameters:
message- The text to add as aString.- Returns:
- A mail object instance
-
textMessage
public Mail textMessage(String template, Map<String, Object> content) throws MangooTemplateEngineExceptionAdds plain message text which uses a given template and content to render- Parameters:
template- The template to rendercontent- The content to pass to the template- Returns:
- A mail object instance
- Throws:
MangooTemplateEngineException- when rendering the template failed
-
htmlMessage
public Mail htmlMessage(String template, Map<String, Object> content) throws MangooTemplateEngineExceptionAdds html message text which uses a given template and content to render- Parameters:
template- The template to rendercontent- The content to pass to the template- Returns:
- A mail object instance
- Throws:
MangooTemplateEngineException- when rendering the template failed
-
send
public void send()Sends the mail -
getMessageHeaders
-
getMessageTos
-
getMessageCcs
-
getMessageBccs
-
getMessageAttachments
-
getMessageSubject
-
getMessageReplyTo
-
getMessageText
-
getMessageFromName
-
getMessageFromAddress
-
isMessageHtml
public boolean isMessageHtml() -
hasAttachments
public boolean hasAttachments()
-