Interface EmailSender

All Known Implementing Classes:
SmtpEmailSender

public interface EmailSender
Sends email messages to third parties.
  • Method Details

    • isEnabled

      boolean isEnabled()
    • canEmail

      boolean canEmail(String address)
      Can the address receive messages from us?
      Parameters:
      address - the address to consider.
      Returns:
      true if this sender will deliver to the address.
    • send

      default void send(Address from, Collection<Address> rcpt, Map<String,EmailHeader> headers, String textBody, String htmlBody) throws com.google.gerrit.exceptions.EmailException
      Sends an email message. Messages always contain a text body, but messages can optionally include an additional HTML body. If both body types are present, send should construct a multipart/alternative message with an appropriately-selected boundary.
      Parameters:
      from - who the message is from.
      rcpt - one or more address where the message will be delivered to. This list overrides any To or CC headers in headers.
      headers - message headers.
      textBody - text to appear in the text/plain body of the message.
      htmlBody - optional HTML code to appear in the text/html body of the message.
      Throws:
      com.google.gerrit.exceptions.EmailException - the message cannot be sent.
    • send

      default void send(Address from, Collection<Address> rcpt, Map<String,EmailHeader> headers, String textBody, String htmlBody, Collection<EmailResource> htmlResources) throws com.google.gerrit.exceptions.EmailException
      Sends an email message. Messages always contain a text body, but messages can optionally include an additional HTML body and related resources. If both body types are present, send should construct a multipart/alternative message with an appropriately-selected boundary. If the HTML Resources are provided then html body and corresponding resources should be grouped as multipart/related.
      Parameters:
      from - who the message is from.
      rcpt - one or more address where the message will be delivered to. This list overrides any To or CC headers in headers.
      headers - message headers.
      textBody - text to appear in the text/plain body of the message.
      htmlBody - optional HTML code to appear in the text/html body of the message.
      htmlResources - optional resources that can be referenced in HTML code using their EmailResource.contentId().
      Throws:
      com.google.gerrit.exceptions.EmailException - the message cannot be sent.
    • send

      void send(Address from, Collection<Address> rcpt, Map<String,EmailHeader> headers, String body) throws com.google.gerrit.exceptions.EmailException
      Sends an email message with a text body only (i.e. not HTML or multipart).

      Authors of new implementations of this interface should not use this method to send a message because this method does not accept the HTML body. Instead, authors should use the above signature of send.

      This version of the method is preserved for support of legacy implementations.

      Parameters:
      from - who the message is from.
      rcpt - one or more address where the message will be delivered to. This list overrides any To or CC headers in headers.
      headers - message headers.
      body - text to appear in the body of the message.
      Throws:
      com.google.gerrit.exceptions.EmailException - the message cannot be sent.