Module ngx_mail_core_module
This module is not built by default, it should be enabled with the --with-mail
configuration parameter.
Example configuration
worker_processes 1; error_log /var/log/nginx/error.log info; mail { server_name mail.example.com; auth_http localhost:9000/cgi-bin/nginxauth.cgi; imap_capabilities IMAP4rev1 UIDPLUS IDLE LITERAL+ QUOTA; pop3_auth plain apop cram-md5; pop3_capabilities LAST TOP USER PIPELINING UIDL; smtp_auth login plain cram-md5; smtp_capabilities "SIZE 10485760" ENHANCEDSTATUSCODES 8BITMIME DSN; xclient off; server { listen 25; protocol smtp; } server { listen 110; protocol pop3; proxy_pass_error_message on; } server { listen 143; protocol imap; } server { listen 587; protocol smtp; } }
Directives
syntax: | listen |
default: | — |
context: | server |
Sets an address
and a port
for for a socket, on which the server will accept requests. Only port may be specified. An address may also be a hostname, for example:
listen 127.0.0.1:110; listen *:110; listen 110; # то же, что и *:110 listen localhost:110;
IPv6 addresses (0.7.58) are specified in square brackets:
listen [::1]:110; listen [::]:110;
UNIX-domain sockets (1.3.5) are specified with the “unix:
” prefix:
listen unix:/var/run/nginx.sock;
The optional bind
parameter instructs to make a separate bind()
call for a given address:port pair. The fact is that nginx will bind()
only to *:
port
if there are several listen
directives with the same port but different addresses, and one of the listen
directives listens on all addresses for the given port (*:
port
). It should be noted that the getsockname()
system call will be made in this case to determine an address that accepted a connection.
Different virtual servers must listen on different address
:port
pairs.
syntax: | protocol |
default: | — |
context: | server |
Sets the protocol of a proxied server. Supported protocols are IMAP, POP3 and SMTP.
If the directive is not set, the protocol can be detected automatically basing on the well-known port specified in the directive:
imap
: 143, 993pop3
: 110, 995smtp
: 25, 587, 465
Unnecessary protocols can be disabled using the configuration parameters --without-mail_imap_module
, --without-mail_pop3_module
and --without-mail_smtp_module
.
syntax: | server { ... } |
default: | — |
context: | mail |
Sets a configuration for the virtual server.
syntax: | server_name |
default: | server_name hostname; |
context: | mail , server |
Sets a name of the virtual server, used:
- in the initial POP3/SMTP server greeting;
- in the salt during the SASL CRAM-MD5 authentication;
- in the
EHLO
command on the SMTP backend connection, if the xclient command is turned on.
syntax: | so_keepalive |
default: | so_keepalive off; |
context: | mail , server |
Controls if the “TCP keepalive” mode should be enabled on the client’s connection (SO_KEEPALIVE
socket parameter) on the proxied server connection.
syntax: | timeout |
default: | timeout 60s; |
context: | mail , server |
Sets the timeout which is used before proxying to the backend started.