Record Class EmailChannelConfig

java.lang.Object
java.lang.Record
com.tnsai.channels.email.EmailChannelConfig
Record Components:
imapHost - IMAP server hostname (e.g. imap.gmail.com)
imapPort - IMAP port (993 for IMAPS, 143 for STARTTLS)
imapUser - IMAP login username
imapPassword - IMAP login password (app-password for Gmail/iCloud)
imapSsl - whether to use SSL/TLS (true for 993, false for 143)
imapFolder - mailbox to poll, defaults to INBOX
smtpHost - SMTP server hostname
smtpPort - SMTP port (587 for STARTTLS, 465 for SMTPS)
smtpUser - SMTP login username
smtpPassword - SMTP login password
smtpStartTls - whether to issue STARTTLS on SMTP (true for 587)
fromAddress - the From header on outbound mail (typically equals smtpUser but Reply-To tricks make this a separate field)
senderAllowlist - addresses that are allowed to reach the agent; comparison is case-insensitive
pollInterval - how often the channel polls IMAP for new mail

public record EmailChannelConfig(String imapHost, int imapPort, String imapUser, String imapPassword, boolean imapSsl, String imapFolder, String smtpHost, int smtpPort, String smtpUser, String smtpPassword, boolean smtpStartTls, String fromAddress, Set<String> senderAllowlist, Duration pollInterval) extends Record
Configuration for EmailChannel.

Values are typically populated from environment variables via fromEnvironment(); programmatic overrides via the builder are intended for tests and per-tenant deployments.

The senderAllowlist is matched against the inbound From address (lowercased via Locale.ROOT) — every email not on the list is silently dropped before reaching the agent. This is intentional: email is the most spammable channel and a blank allowlist means "process nothing".

  • Field Details

    • DEFAULT_POLL_INTERVAL

      public static final Duration DEFAULT_POLL_INTERVAL
      Default poll interval — 60 seconds, per TNS-354 acceptance ("5 minute response").
    • DEFAULT_IMAP_PORT

      public static final int DEFAULT_IMAP_PORT
      Default IMAPS port.
      See Also:
    • DEFAULT_SMTP_PORT

      public static final int DEFAULT_SMTP_PORT
      Default SMTP+STARTTLS port.
      See Also:
  • Constructor Details

    • EmailChannelConfig

      public EmailChannelConfig(String imapHost, int imapPort, String imapUser, String imapPassword, boolean imapSsl, String imapFolder, String smtpHost, int smtpPort, String smtpUser, String smtpPassword, boolean smtpStartTls, String fromAddress, Set<String> senderAllowlist, Duration pollInterval)
      Creates an instance of a EmailChannelConfig record class.
      Parameters:
      imapHost - the value for the imapHost record component
      imapPort - the value for the imapPort record component
      imapUser - the value for the imapUser record component
      imapPassword - the value for the imapPassword record component
      imapSsl - the value for the imapSsl record component
      imapFolder - the value for the imapFolder record component
      smtpHost - the value for the smtpHost record component
      smtpPort - the value for the smtpPort record component
      smtpUser - the value for the smtpUser record component
      smtpPassword - the value for the smtpPassword record component
      smtpStartTls - the value for the smtpStartTls record component
      fromAddress - the value for the fromAddress record component
      senderAllowlist - the value for the senderAllowlist record component
      pollInterval - the value for the pollInterval record component
  • Method Details

    • isAllowed

      public boolean isAllowed(String fromAddress)
      true when the From address is on the allowlist.
    • fromEnvironment

      public static Optional<EmailChannelConfig> fromEnvironment()
      Populate from environment variables. Missing required vars return Optional.empty() so the channel can decline to start without raising an exception.

      Recognised vars: EMAIL_IMAP_HOST, EMAIL_IMAP_PORT, EMAIL_IMAP_USER, EMAIL_IMAP_PASSWORD, EMAIL_IMAP_SSL, EMAIL_IMAP_FOLDER, EMAIL_SMTP_HOST, EMAIL_SMTP_PORT, EMAIL_SMTP_USER, EMAIL_SMTP_PASSWORD, EMAIL_SMTP_STARTTLS, EMAIL_FROM_ADDRESS, EMAIL_SENDER_ALLOWLIST (comma-separated), EMAIL_POLL_INTERVAL_SECONDS.

    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • imapHost

      public String imapHost()
      Returns the value of the imapHost record component.
      Returns:
      the value of the imapHost record component
    • imapPort

      public int imapPort()
      Returns the value of the imapPort record component.
      Returns:
      the value of the imapPort record component
    • imapUser

      public String imapUser()
      Returns the value of the imapUser record component.
      Returns:
      the value of the imapUser record component
    • imapPassword

      public String imapPassword()
      Returns the value of the imapPassword record component.
      Returns:
      the value of the imapPassword record component
    • imapSsl

      public boolean imapSsl()
      Returns the value of the imapSsl record component.
      Returns:
      the value of the imapSsl record component
    • imapFolder

      public String imapFolder()
      Returns the value of the imapFolder record component.
      Returns:
      the value of the imapFolder record component
    • smtpHost

      public String smtpHost()
      Returns the value of the smtpHost record component.
      Returns:
      the value of the smtpHost record component
    • smtpPort

      public int smtpPort()
      Returns the value of the smtpPort record component.
      Returns:
      the value of the smtpPort record component
    • smtpUser

      public String smtpUser()
      Returns the value of the smtpUser record component.
      Returns:
      the value of the smtpUser record component
    • smtpPassword

      public String smtpPassword()
      Returns the value of the smtpPassword record component.
      Returns:
      the value of the smtpPassword record component
    • smtpStartTls

      public boolean smtpStartTls()
      Returns the value of the smtpStartTls record component.
      Returns:
      the value of the smtpStartTls record component
    • fromAddress

      public String fromAddress()
      Returns the value of the fromAddress record component.
      Returns:
      the value of the fromAddress record component
    • senderAllowlist

      public Set<String> senderAllowlist()
      Returns the value of the senderAllowlist record component.
      Returns:
      the value of the senderAllowlist record component
    • pollInterval

      public Duration pollInterval()
      Returns the value of the pollInterval record component.
      Returns:
      the value of the pollInterval record component