max_errors
The `max_errors` directive sets the maximum number of errors allowed when connecting to mail servers.
Description
max_errors is a directive defined in the NGINX Mail Core module that specifies the maximum number of connection errors to a mail server that the NGINX instance should tolerate. When the number of connection errors exceeds the specified limit, NGINX will stop attempting to connect to that mail server. This is useful for preventing NGINX from continuously trying to connect to an unresponsive server, which could waste resources and lead to performance degradation.
The directive takes an integer argument that indicates the maximum error count. For example, if you set max_errors 3;, after three consecutive connection failures, NGINX will cease attempts to connect to the problematic mail server until it is manually re-enabled or the NGINX service is restarted. This setting can be crucial for maintaining a healthy and responsive mail service, especially in environments with multiple mail servers, as it allows other operational servers to be used efficiently without getting bogged down by persistent connection issues with one particular server.
Config Example
mail {
server {
listen 25;
# Define the maximum errors
max_errors 3;
# Additional configurations here...
}
}The max_errors directive only applies to mail server connections and does not affect other types of connections.
Setting the value too low may lead to ignoring transient issues with mail servers that could resolve quickly.
Make sure to monitor the logs; otherwise, you might not be aware of repeated connection failures.