Class Mail.Builder

java.lang.Object
com.codename1.backend.mail.Mail.Builder
Enclosing class:
Mail

public static final class Mail.Builder extends Object
Collects a mail's parts; build() checks them.
  • Method Details

    • from

      public Mail.Builder from(String address)
      The sender. Without one the mail is sent from cn1.mail.from.
    • replyTo

      public Mail.Builder replyTo(String address)
      Where a reply goes when that is not the sender.
    • to

      public Mail.Builder to(String... addresses)
      Adds recipients.
    • cc

      public Mail.Builder cc(String... addresses)
      Adds recipients every other recipient can see were copied.
    • bcc

      public Mail.Builder bcc(String... addresses)
      Adds recipients no other recipient is told about.
    • subject

      public Mail.Builder subject(String subject)
      The subject line; any language, one line.
    • text

      public Mail.Builder text(String text)
      The plain text body.
    • html

      public Mail.Builder html(String html)
      The HTML body.
    • template

      public Mail.Builder template(String view, Model model)
      The HTML body, rendered from the template templates/<view>.html with model when the mail is sent. The text body is derived from what was rendered, unless text gave one.
    • attach

      public Mail.Builder attach(String name, String type, byte[] data)

      Attaches a file.

      • name: the file name the reader sees
      • type: its media type, such as application/pdf; null for application/octet-stream
      • data: its content, which the mail keeps and does not copy
    • inline

      public Mail.Builder inline(String contentId, String type, byte[] data)
      Embeds an image the HTML body shows with <img src="cid:contentId">.
    • header

      public Mail.Builder header(String name, String value)
      Adds a header of the application's own, such as List-Unsubscribe or X-Campaign. The headers a mail is built from -- the addresses, the subject, the date, the content headers -- cannot be set here.
    • build

      public Mail build()
      Checks everything and answers the mail, or throws IllegalArgumentException naming what is wrong.