java.lang.Object
i2p.susi.webmail.smtp.SMTPClient

public class SMTPClientextends Object
SMTP client for sending email through SMTP servers over I2P. Supports command pipelining, attachments, and size limits optimized for I2P. Includes base64 size calculations and 8BITMIME support for efficient I2P mail delivery.
  • Field Details

    • DEFAULT_MAX_SIZE

      public static final long DEFAULT_MAX_SIZE
      10.00 MB smtp.postman.i2p as of 2024-06-22.
      See Also:
    • BINARY_MAX_SIZE

      public static final long BINARY_MAX_SIZE
      7629902 ~= 7.27 MB Base64 encodes 57 chars to 76 + \r\n on a line.
      See Also:
    • error

      public String error
      Error message from the last failed operation, or empty if none.
  • Constructor Details

    • SMTPClient

      public SMTPClient()
      Creates a client with no error.
  • Method Details

    • sendMail

      public boolean sendMail(String host, int port, String user, String pass, String sender, List<String> recipients, StringBuilder body, List<Attachment> attachments, String boundary)
      Sends one message to an SMTP server, authenticating first when a user name is given. Any failure is appended to the error field rather than thrown.
      Parameters:
      host - the SMTP server to connect to
      port - the SMTP server port to connect to
      user - the AUTH LOGIN user name, base64-encoded on the wire
      pass - the AUTH LOGIN password, base64-encoded on the wire
      sender - the envelope sender, sent as MAIL FROM
      recipients - the envelope recipients, sent as one RCPT TO each
      body - headers and body, without the attachments
      attachments - may be null
      boundary - non-null if attachments is non-null
      Returns:
      true if the server accepted the message, false if any step failed
    • writeMail

      public static void writeMail(Writer out, StringBuilder body, List<Attachment> attachments, String boundary) throws IOException
      Caller must close out.
      Parameters:
      out - the writer that receives the message, left open for the caller
      body - headers and body, without the attachments
      attachments - may be null
      boundary - non-null if attachments is non-null
      Throws:
      IOException - if the socket write or the attachment encoding fails