Interface InboundMail


public interface InboundMail
An incoming email message, which records what a handler did with it.

Cloudflare drops a message that a handler returns without acting on, so this type keeps the disposition rather than making the handler return one. Act at any point and carry on:

 public void email(InboundMail mail, Env env, ExecutionCtx ctx) {
 	mail.reply(acknowledgement(mail));
 	audit(env, mail.from());
 	mail.forward("[email protected]");
 }

Inbound messages are capped at 25 MiB. A reply is refused unless the original passed DMARC, the recipient matches the original sender, the sending domain matches the receiving domain, only one reply is sent per message, and the References header holds fewer than 100 entries.

Since:
1.0.0
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns what has been done with this message so far.
    void
    Discards the message on purpose.
    void
    forward(String address)
    Sends the message on to a verified destination address.
    Returns the envelope sender.
    Returns the message headers.
    raw()
    Returns the raw MIME message.
    int
    Returns the size of the raw message in bytes.
    void
    reject(String reason)
    Refuses the message with a permanent SMTP error.
    void
    reply(String mime)
    Answers the message in the same SMTP session.
    to()
    Returns the envelope recipient.
  • Method Details

    • from

      String from()
      Returns the envelope sender.
      Returns:
      the envelope sender
    • to

      String to()
      Returns the envelope recipient.
      Returns:
      the envelope recipient
    • headers

      Headers headers()
      Returns the message headers.
      Returns:
      the message headers
    • rawSize

      int rawSize()
      Returns the size of the raw message in bytes.
      Returns:
      the size of the raw message in bytes
    • raw

      String raw()
      Returns the raw MIME message.
      Returns:
      the raw MIME message
    • disposition

      MailAction disposition()
      Returns what has been done with this message so far.
      Returns:
      what has been done with this message so far
    • forward

      void forward(String address)
      Sends the message on to a verified destination address.
      Parameters:
      address - the destination
    • reply

      void reply(String mime)
      Answers the message in the same SMTP session.
      Parameters:
      mime - the reply, as a raw MIME message
    • reject

      void reject(String reason)
      Refuses the message with a permanent SMTP error.
      Parameters:
      reason - the reason, returned to the sending server
    • drop

      void drop()
      Discards the message on purpose.