Package gda.util

Class Email

java.lang.Object
gda.util.Email

public class Email extends Object
Utility builder for sending emails. Messages can be built and sent with a fluent api, eg
  new Email().to("foobar@diamond.ac.uk")
                .subject("This is a test message")
                .message("This is the message body")
                .attach("/path/to/file")
                .attach("/path/to/additional_file")
                .send();
  
  • Constructor Details

    • Email

      public Email()
  • Method Details

    • to

      public Email to(Collection<String> address)
      Add addresses to be the main recipients of this message
    • to

      public Email to(String... address)
      Add addresses to be the main recipients of this message
    • cc

      public Email cc(Collection<String> cc)
      Add addresses to be included in the CC list of this message
    • cc

      public Email cc(String... cc)
      Add addresses to be included in the CC list of this message
    • bcc

      public Email bcc(Collection<String> bcc)
      Add addresses to be included in the BCC list of this message
    • bcc

      public Email bcc(String... bcc)
      Add addresses to be included in the BCC list of this message
    • subject

      public Email subject(String subject)
      Set the subject of this message
    • message

      public Email message(String message)
      Set the body text of this message
    • attach

      public Email attach(Collection<String> attachments)
      Add an attachment to this message
    • attach

      public Email attach(String... attachments)
      Add an attachment to this message
    • from

      public Email from(String name, String address)
      Set the address that this message will appear to be from
    • send

      public void send() throws javax.mail.MessagingException
      Send message
      Throws:
      javax.mail.MessagingException
    • sendAsync

      public Future<?> sendAsync()
      Send message in a background thread
      Returns:
      a future giving access to the completion status