Class Mail
java.lang.Object
com.codename1.backend.mail.Mail
One email: who it is for, what it says and what is attached.
mail.send(Mail.to("ada@example.com")
.subject("Your order shipped")
.template("mail/shipped", model)
.attach("invoice.pdf", "application/pdf", pdf)
.build());
This one class is what Spring spreads over SimpleMailMessage,
MimeMessage and MimeMessageHelper. It is immutable; everything is
checked in Mail.Builder.build(), so a mail that exists can be sent: an address
that is not one, a header with a line break in it or an attachment with no
name fails there, with an IllegalArgumentException, never at the server.
A mail with an HTML body and no text is given a text alternative derived from the HTML, which is what keeps it out of spam folders and readable in a client that shows text. The body is always UTF-8.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classCollects a mail's parts;Mail.Builder.build()checks them. -
Method Summary
Modifier and TypeMethodDescriptionstatic Mail.Builderbuilder()Starts a mail with no recipient yet.byte[]getAttachment(String name) The content of the attachment calledname, or null.The file names of the attachments, in order.getBcc()The addresses copied without the other recipients being told.getCc()The addresses copied.getFrom()The sender as it was given, or null when the mail takes the default.The value of a header added withMail.Builder.header(String, String), or null.getHtml()The HTML body, or null.The reply address, or null.The subject, or null.getText()The text body.getTo()The addresses of the recipients, without their display names.static booleanWhetheraddressis a bareuser@example.coma mail can be sent to; answers without throwing.static Mail.BuilderStarts a mail toaddresses, eachuser@example.comorName <user@example.com>.
-
Method Details
-
to
Starts a mail toaddresses, eachuser@example.comorName <user@example.com>. -
isAddress
Whetheraddressis a bareuser@example.coma mail can be sent to; answers without throwing. -
builder
Starts a mail with no recipient yet. -
getFrom
The sender as it was given, or null when the mail takes the default. -
getReplyTo
The reply address, or null. -
getTo
-
getCc
-
getBcc
-
getSubject
The subject, or null. -
getText
The text body. For a mail built from a template this is null until the mail is sent; the mail a test captures has it. -
getHtml
The HTML body, or null. For a mail built from a template this is null until the mail is sent; the mail a test captures has it. -
getAttachmentNames
-
getAttachment
The content of the attachment calledname, or null. -
getHeader
The value of a header added withMail.Builder.header(String, String), or null. The name is matched without regard to case.
-