Class SesTransport

java.lang.Object
com.codename1.backend.mail.MailTransport
com.codename1.backend.mail.ses.SesTransport

public final class SesTransport extends MailTransport

Sends mail through Amazon SES, by its API rather than its SMTP endpoint: one signed HTTPS request a mail, and no SMTP credentials to issue.

cn1.mail.url=ses://eu-west-1

Credentials are the machine's own -- the environment, a container role or an instance role -- found as for every other AWS service here. The sender has to be an identity SES has verified.

Setting Default
cn1.mail.ses.configuration-set the configuration set a mail is sent with
cn1.mail.ses.region us-east-1 the region to sign for, when the URL names a host and not a region

The mail is handed over as it was encoded, so what arrives is what an SMTP server would have been given. SES takes at most 50 recipients a request; a mail to more is sent in several. ses://localhost:4566 names an endpoint instead of a region, for a stand-in on the same machine.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    Opens ses: URLs; what the generated wiring registers.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SesTransport(String url, String region, String configurationSet)
    A transport for url.
    SesTransport(String url, String region, String configurationSet, Credentials fixed)
    A transport for url that signs with fixed rather than with what the environment, the container or the instance provides -- for an account other than the one the server runs as.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes connections it holds.
    What this transport is: smtp, ses, memory, log.
    boolean
    Whether the transport could reach its server the last time it tried.
    void
    send(String from, String[] recipients, byte[] mime)
    Hands one mail over, returning when the other side has taken it.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SesTransport

      public SesTransport(String url, String region, String configurationSet) throws IOException

      A transport for url.

      • region: the region to sign for when url names a host; may be null
      • configurationSet: the configuration set to send with, or null
      Throws:
      IOException
    • SesTransport

      public SesTransport(String url, String region, String configurationSet, Credentials fixed) throws IOException

      A transport for url that signs with fixed rather than with what the environment, the container or the instance provides -- for an account other than the one the server runs as. Credentials given this way are never refreshed, so they should not be ones that expire.

      • region: the region to sign for when url names a host; may be null
      • configurationSet: the configuration set to send with, or null
      • fixed: the credentials to sign with, or null to resolve them
      Throws:
      IOException
  • Method Details

    • getName

      public String getName()
      Description copied from class: MailTransport
      What this transport is: smtp, ses, memory, log.
      Specified by:
      getName in class MailTransport
    • send

      public void send(String from, String[] recipients, byte[] mime) throws IOException
      Description copied from class: MailTransport

      Hands one mail over, returning when the other side has taken it.

      Throws a MailException whose MailException.isPermanent() says whether trying again could help; any other IOException is taken to be a failure of the connection, and is retried.

      • from: the address a bounce goes to, without a display name
      • recipients: the addresses to deliver to, without display names
      • mime: the whole message, CRLF line endings, not dot-stuffed
      Specified by:
      send in class MailTransport
      Throws:
      IOException
    • isHealthy

      public boolean isHealthy()
      Description copied from class: MailTransport
      Whether the transport could reach its server the last time it tried. One that has not tried yet is healthy.
      Overrides:
      isHealthy in class MailTransport
    • close

      public void close()
      Description copied from class: MailTransport
      Closes connections it holds. Never throws.
      Specified by:
      close in class MailTransport