Class MailTransport

java.lang.Object
com.codename1.backend.mail.MailTransport
Direct Known Subclasses:
SesTransport, SmtpTransport

public abstract class MailTransport extends Object

One way of handing an encoded mail to something that will deliver it: an SMTP server, a provider's API.

A transport is given the envelope and the bytes and nothing else. It does not queue, retry or keep anything; the server's Mailer does that around it, the same way for every transport. It is called from the mail thread and from any thread that calls MailSender.sendNow(Mail), so it is safe to call from several at once.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract void
    Closes connections it holds.
    abstract String
    What this transport is: smtp, ses, memory, log.
    boolean
    Whether the transport could reach its server the last time it tried.
    abstract 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

    • MailTransport

      public MailTransport()
  • Method Details

    • getName

      public abstract String getName()
      What this transport is: smtp, ses, memory, log.
    • send

      public abstract void send(String from, String[] recipients, byte[] mime) throws IOException

      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
      Throws:
      IOException
    • isHealthy

      public boolean isHealthy()
      Whether the transport could reach its server the last time it tried. One that has not tried yet is healthy.
    • close

      public abstract void close()
      Closes connections it holds. Never throws.