mail

The 'mail' directive is used to enable the mail processing module in NGINX, allowing it to handle email protocols like IMAP and POP3. — NGINX Core

mail
main
Синтаксисmail;
По умолчаниюnone
Контекстmain
МодульNGINX Core
Аргументыnone

Описание

The 'mail' directive in NGINX is pivotal for enabling the mail processing functionalities provided by the mail module. When declared at the main context of the configuration, it activates the capability for NGINX to act as a mail proxy server, handling protocols such as IMAP, POP3, and SMTP. This directive does not accept any parameters or arguments; its mere presence in the configuration indicates that mail functionalities should be included in the NGINX operations. Upon initializing, the mail module configures its settings based on additional, related mail-specific directives that follow the 'mail' directive in the configuration file. These include directives that define server and user credentials, authentication methods, and upstream servers. It is notable that this directive alone does not process any mail; rather, it sets the groundwork for subsequent configurations that specify how NGINX should interface with mail clients and mail servers. The directive plays a critical role in ensuring that NGINX can effectively manage and forward email requests, interacting seamlessly with existing mail infrastructure. By integrating mail protocols, NGINX extends its versatility beyond static and dynamic web content serving to include robust email handling capabilities, which can be especially beneficial in load-balanced environments or when consolidating multiple services into a unified architecture.

Пример конфига

mail {
    server {
        listen 110;
        protocol pop3;
        proxy on;
    }
    server {
        listen 143;
        protocol imap;
        proxy on;
    }
}

Ensure that additional directives for mail protocols and authentication are defined; otherwise, the mail functionality will be incomplete.

Remember that this directive must be used in the main context and cannot be included within server or location blocks.

You may need to adjust firewall settings to allow traffic over mail ports such as TCP 110 and 143.