Package io.mangoo.email
Class Mail
- java.lang.Object
-
- io.mangoo.email.Mail
-
public class Mail extends Object
- Author:
- svenkubiak
-
-
Constructor Summary
Constructors Constructor Description Mail()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Mailattachment(File file)Adds a file as attachment to the mailMailbcc(String bcc)Appends BCC address.Mailbcc(String... bccs)Appends BCC addressMailcc(String cc)Appends CC addressMailcc(String... ccs)Sets one or more CC addressMailfrom(String fromName, String fromAddress)Sets the FROM address and nameMailheader(String name, String value)Sets header value.MailhtmlMessage(String message)Adds html message text.MailhtmlMessage(String template, Map<String,Object> content)Adds html message text which uses a given template and content to renderstatic MailnewMail()Creates a new mail instanceMailpriority(int priority)Sets the email priorityMailreplyTo(String replyTo)Appends REPLY-TO addressvoidsend()Sends the mailMailsubject(String subject)Sets message subject with specified encoding to override default platform encoding.MailtextMessage(String message)Adds plain message textMailtextMessage(String template, Map<String,Object> content)Adds plain message text which uses a given template and content to renderMailto(String to)Appends TO addressMailto(String... tos)Appends one or more TO address
-
-
-
Method Detail
-
newMail
public static Mail newMail()
Creates a new mail instance- Returns:
- A mail object instance
-
to
public Mail to(String... tos)
Appends 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
-
to
public Mail to(String to)
Appends TO address- Parameters:
to- Address may be specified with personal name like this:Jenny Doe <email@foo.com>.- Returns:
- A mail object instance
-
cc
public Mail cc(String... ccs)
Sets one or more CC address- Parameters:
ccs- array ofStrings to set.- Returns:
- A mail object instance
-
cc
public Mail cc(String cc)
Appends CC address- Parameters:
cc- Address may be specified with personal name like this:Jenny Doe <email@foo.com>.- Returns:
- A mail object instance
-
bcc
public Mail bcc(String... bccs)
Appends BCC address- Parameters:
bccs- array ofStrings to set.- Returns:
- A mail object instance
-
bcc
public Mail bcc(String bcc)
Appends BCC address.- Parameters:
bcc- Address may be specified with personal name like this:Jenny Doe <email@foo.com>.- Returns:
- A mail object instance
-
subject
public Mail subject(String 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. SeeMimeMessage.setSubject(String, String).- Parameters:
subject- The message subject- Returns:
- A mail object instance
-
from
public Mail from(String fromName, String fromAddress)
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
-
header
public Mail header(String name, String value)
Sets header value.- Parameters:
name- The name of the headervalue- The value of the header- Returns:
- A mail object instance
-
replyTo
public Mail replyTo(String replyTo)
Appends 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
public Mail priority(int priority)
Sets the email priority- Parameters:
priority- - 1 being the highest priority, 3 = normal and 5 = lowest priority.- Returns:
- A mail object instance
-
attachment
public Mail attachment(File file)
Adds a file as attachment to the mail- Parameters:
file- The File to attach- Returns:
- A mail object instance
-
textMessage
public Mail textMessage(String message)
Adds plain message text- Parameters:
message- The text to add as aString.- Returns:
- A mail object instance
-
htmlMessage
public Mail htmlMessage(String message)
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 MangooTemplateEngineException
Adds 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 MangooTemplateEngineException
Adds 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() throws MangooMailerExceptionSends the mail- Throws:
MangooMailerException- when sending the mail failed
-
-