Dovecot Core
repository·main·Indexed 22 days ago
https://github.com/dovecot/coreA powerful and flexible IMAP/POP3/LMTP mail server designed for high performance, security, and scalability. This repository contains the core server implementation, including the anvil connection manager, authentication services, the Local Delivery Agent (dovecot-lda), and IMAP/LMTP server components.
What's inside dovecot-core
- Dovecot provides SSL/TLS functionality via support for the OpenSSL library.
Run Dovecot after installation
mainAfter installation, Dovecot's minimal configuration files are located in
/usr/local/etc/dovecot/.To run the service:
- Review and modify the configuration files in
/usr/local/etc/dovecot/to suit your requirements. - Execute the
dovecotbinary to start the service.
- Review and modify the configuration files in
Install Dovecot
mainFor detailed installation instructions, refer to theINSTALL.mdfile in the repository.Build and install Dovecot from source
mainTo build and install Dovecot, use the standard autotools workflow. If you are building directly from a git repository, you must run
./autogen.shbefore configuring. By default, Dovecot installs to/usr/local.If your dependencies (like OpenSSL) are in non-standard locations, use
CPPFLAGSfor include paths andLDFLAGSfor library paths during the configuration step.Configure Dovecot
mainComprehensive configuration guides and documentation are available at the official Dovecot documentation website: https://doc.dovecot.org.Run the Dovecot dict service
mainThedictservice is a Dovecot component that provides a dictionary interface for various backends (like SQL or CDB). It is managed by the Dovecotmasterservice. When running as a standalone process, it initializes drivers, commands, and connections, and then enters a loop to accept client connections via the master service interface.Submission protocol client implementation details
mainThe
submission-loginprocess implements the Dovecot submission protocol (typically on port 587). It acts as a proxy/client that manages SMTP connections to a backend.Key behaviors:
- Capabilities: It supports standard SMTP capabilities including
SIZE,ENHANCEDSTATUSCODES,AUTH, andXCLIENT. It also supportsSTARTTLSif TLS is enabled on the client connection. - XCLIENT Support: It handles
XCLIENTcommands to extract proxy information such as source/destination IP, ports, and TTL. It specifically supports aFORWARDparameter which is decoded from Base64. - Security: It enforces a limit on bad commands (
CLIENT_MAX_BAD_COMMANDS = 10) before disconnecting the client. It also manages TLS initialization viaSTARTTLS. - Backend Capabilities: The backend capabilities can be configured via
submission_backend_capabilities. If not explicitly set, it defaults to8BITMIME(andSMTPUTF8ifmail_utf8_extensionsis enabled). IfBINARYMIMEis enabled,CHUNKINGis automatically enabled.
- Capabilities: It supports standard SMTP capabilities including
Understand the submission_proxy_state enumeration
mainThe
submission_proxy_stateenum tracks the current stage of the Submission protocol proxy lifecycle. It defines the sequence of states a client transitions through when proxying submission connections, starting from the initial banner through EHLO, TLS negotiation, XCLIENT handling, and finally authentication.Available states:
SUBMISSION_PROXY_BANNER: Initial connection banner.SUBMISSION_PROXY_EHLO: Handling the EHLO command.SUBMISSION_PROXY_STARTTLS: Handling STARTTLS negotiation.SUBMISSION_PROXY_TLS_EHLO: Handling EHLO after TLS is established.SUBMISSION_PROXY_XCLIENT: Handling XCLIENT commands.SUBMISSION_PROXY_XCLIENT_EHLO: Handling EHLO after XCLIENT.SUBMISSION_PROXY_AUTHENTICATE: Handling the authentication phase.
enum submission_proxy_state { SUBMISSION_PROXY_BANNER = 0, SUBMISSION_PROXY_EHLO, SUBMISSION_PROXY_STARTTLS, SUBMISSION_PROXY_TLS_EHLO, SUBMISSION_PROXY_XCLIENT, SUBMISSION_PROXY_XCLIENT_EHLO, SUBMISSION_PROXY_AUTHENTICATE, SUBMISSION_PROXY_STATE_COUNT };Run LMTP in standalone mode via STDIN/STDOUT
mainThe LMTP server can be run in a standalone mode (bypassing the master process) by ensuring theMASTER_IS_PARENT_ENVenvironment variable is not set. In this mode, the server reads fromSTDIN_FILENOand writes toSTDOUT_FILENO. This is typically used for testing or specialized local piping.How the Dovecot config process lifecycle works
mainThe
configprocess in Dovecot is managed by themaster_service. It follows a specific lifecycle to ensure configuration is parsed correctly before the master service considers the process healthy.- Initialization: The service is initialized via
master_service_initwith specific flags (e.g.,MASTER_SERVICE_FLAG_DONT_SEND_STATS). - Security & Environment: Access is restricted using
restrict_access_by_envand coredumps are managed viarestrict_access_allow_coredumps. - Configuration Loading: Modules are loaded via
config_parse_load_modulesand settings are configured usingsettings_set_config_binary. - Service Readiness: Crucially,
master_service_init_finishis called only after the configuration file has been successfully parsed. This prevents the master service from entering a crash loop by attempting to restart a process that is failing due to invalid configuration. - Execution: The process enters its main loop via
master_service_run, accepting connections through a callback (e.g.,client_connected) that handles connection creation viaconfig_connection_create. - Cleanup: Upon exit, connections are destroyed, and modules/parsers are deinitialized in a specific order to prevent unmapping event categories before they are used.
- Initialization: The service is initialized via
How the POP3 server handles standalone vs master mode
mainThe POP3 server can operate in two distinct modes based on the environment:
Standalone Mode: Detected when the
MASTER_IS_PARENT_ENVenvironment variable is not set. In this mode, the server reads input fromSTDINand writes toSTDOUT. It is intended for simple testing or specific local use cases. It is explicitly forbidden to start the POP3 binary frominetdif running as root in standalone mode; instead,pop3-loginshould be used.Master Mode: The standard operational mode where the POP3 process acts as a service managed by Dovecot's master process. It uses a
login_serverto handle authentication requests and amail_storage_serviceto manage mail access. It listens on sockets defined in the master configuration.
Configure IMAP process title visibility
mainThe IMAP server can display detailed process titles (e.g., showing the username, remote IP, and current command) in the process list. This is controlled by theverbose_proctitleglobal variable. When enabled, the server periodically refreshes the process title to reflect the current state of active connections.