Class MailProps

All Implemented Interfaces:
EventListener, IGProp<GProp<?>[]>, IPropCnr, Cloneable
Direct Known Subclasses:
EditorMailProps

public class MailProps extends PropCnr
Container holding mail settings.
Author:
Christopher Mindus
  • Field Details

    • COMPRESS

      public static final String COMPRESS
      Property name, saved mail compression type: 0=none, 1=gzip (default), 2=xz.
      See Also:
    • DEBUG

      public static final String DEBUG
      Property name, debug: "debug", default false.
      See Also:
    • QUEUED_MAIL_DIRECTORY

      public static final String QUEUED_MAIL_DIRECTORY
      Property name: queued mail directory: "directory".
      See Also:
    • DEFAULT_SENDER

      public static final String DEFAULT_SENDER
      Property name, default sender: "defaultSender".
      See Also:
    • DEFAULT_REPLYTO

      public static final String DEFAULT_REPLYTO
      Property name, default sender: "defaultReplyTo".
      See Also:
    • DEFAULT_CCS

      public static final String DEFAULT_CCS
      Property name, default sender: "defaultCCs".
      See Also:
    • DEFAULT_BCCS

      public static final String DEFAULT_BCCS
      Property name, default sender: "defaultBCCs".
      See Also:
    • MAIL_HOST

      public static final String MAIL_HOST
      Property name, mail host: "host".
      See Also:
    • PORT

      public static final String PORT
      Property name, mail port: "port" (1-65534, default 25).
      See Also:
    • BIND_ADDRESS

      public static final String BIND_ADDRESS
      Property name, mail bind port, default null for none.
      See Also:
    • SMTPS_PROTOCOL

      public static final String SMTPS_PROTOCOL
      Property name, mail host: "smtps".
      See Also:
    • USE_SSL

      public static final String USE_SSL
      Property name: enable SSL: "ssl".
      See Also:
    • USE_STARTTLS

      public static final String USE_STARTTLS
      Property name: use STARTTLS: "STARTTLS".
      See Also:
    • SERVER_IDENTITY_CHECK

      public static final String SERVER_IDENTITY_CHECK
      Server identity check: "serverIDCheck.

      RFC 2595 specifies addition checks that must be performed on the server's certificate to ensure that the server you connected to is the server you intended to connect to. This reduces the risk of "man in the middle" attacks.

      See Also:
    • TIMEOUT

      public static final String TIMEOUT
      Property name, timeout in milliseconds: "timeout".
      See Also:
    • USER_NAME

      public static final String USER_NAME
      The user name property string: "userName" (a StringProp).
      See Also:
    • PASSWORD

      public static final String PASSWORD
      The password property name: "password" (a PasswordProp).
      See Also:
  • Constructor Details

    • MailProps

      public MailProps()
      Creates the container properties without a name.
    • MailProps

      public MailProps(Atom atom)
      Creates the container properties with a name.
      Parameters:
      atom - The atom name.
  • Method Details

    • clone

      public MailProps clone()
      Clone must be overridden.
      Overrides:
      clone in class PropCnr
    • getMailQueueDirectory

      public File getMailQueueDirectory(File baseDir)
      Gets the send mail queue directory to use.
      Parameters:
      baseDir - The base directory where the server is (generally current directory).
      Returns:
      The mail directory, null for failure.
    • isDefaultSender

      public boolean isDefaultSender()
      Returns if this is the default mail sender: the container marked by Atom.DEFAULT ($default), which is also what MailSender and the server settings' verification read; a container without the mark counts as marked, so a configuration with one sender has it as the default. Until CC-SERVERADMIN-MAIL-SENDERS (MG-D-15) this read the boolean of DEFAULT_SENDER - the sender's address string - and was always false.
      Returns:
      true if default, false otherwise.
    • setDefaultSender

      public void setDefaultSender(boolean isDefault)
      Marks or unmarks this container as the default mail sender ($default). The mark is written in both states, so that a configuration with several senders names its default (ServerAdmin's Mail page moves it with "Make default": exactly one container marked).
      Parameters:
      isDefault - true to mark it as the default, false to unmark it.
    • findDefaultSender

      public static MailProps findDefaultSender(MailProps[] senders)
      Finds the default mail sender among containers, the one rule of the server: the first container MARKED $default=true (ServerAdmin's "Make default", MS-D-1 ruled 2026-10-25: never a sender found by its name, and never an unmarked one standing before the marked one - CC-FIX-LEFTOVERS-1026); else the first container that isDefaultSender() says is the default (an unmarked one, when nothing is marked); else the first container at all (a configuration whose every sender is unmarked still has a default); else null.
      Parameters:
      senders - The mail sender containers, in configuration order.
      Returns:
      The default sender's container, or null when there is none.
    • getMailSender

      public MailSender getMailSender()
      Gets the current mail sender.
      Returns:
      The instance created, or null if not yet created.
    • resetInstance

      public void resetInstance()
      Drops the mail sender built from this container, after its properties changed (ServerAdmin's Mail card, CC-FIX-MLS-GOLIVE-FINDINGS): the sender is disposed of - its unsent mail stays queued in the directory - and createInstance(ExecutorService, File) builds the next one from the current values, which queues that mail again.
    • getDefaultSender

      public InternetAddress getDefaultSender() throws AddressException
      Gets the Default Sender.
      Returns:
      The address, or null for none.
      Throws:
      AddressException - If the address is invalid.
    • getDefaultReplyTo

      public InternetAddress getDefaultReplyTo() throws AddressException
      Gets the Default Reply To.
      Returns:
      The address, or null for none.
      Throws:
      AddressException - If the address is invalid.
    • getDefaultCCs

      public InternetAddress[] getDefaultCCs() throws AddressException
      Gets the Default CCs.
      Returns:
      The address array "never zero in length", or null for none.
      Throws:
      AddressException - If the address is invalid.
    • getDefaultBCCs

      public InternetAddress[] getDefaultBCCs() throws AddressException
      Gets the Default BCCs.
      Returns:
      The address array "never zero in length", or null for none.
      Throws:
      AddressException - If the address is invalid.
    • createInstance

      public MailSender createInstance(ExecutorService executorService, File baseDir) throws IOException, NoSuchProviderException, AddressException
      Constructs the mail sender from the property if not already done.
      Parameters:
      executorService - The executor service.
      baseDir - The base directory where the server is (generally current directory).
      Returns:
      The instance created, or the existing one.
      Throws:
      IOException - If the mail queue directory does not exist.
      NoSuchProviderException - If the "smtp" or "smtps" providers do not exist!
      AddressException - If the default sender failed to parse.
    • verify

      public boolean verify(PropVerification verification)
      Verifies this property container. The check performed is the extension of classes and that no circular reference is present.
      Specified by:
      verify in interface IGProp<GProp<?>[]>
      Overrides:
      verify in class PropCnr
      Parameters:
      verification - The property verification class.
      Returns:
      true if verification should proceed, false if disposed of and verification should not take place.