Kennisbank
1.000 veelgestelde vragen, 500 tutorials en uitlegvideo's. Hier vind je alleen maar oplossingen!
Manage automated IMAP connections and prevent disconnections
This guide explains how automated IMAP connections work (e.g., for scripts, services, or IMAP to MQTT bridges), how to use the IDLE command, and best practices to ensure the continuity of your application.
Introduction
- Checking an email inbox via secure IMAP (SSL/TLS) every 5 seconds, rather than every 15 seconds or more, does not, in itself, trigger an automatic ban of your IP address on Infomaniak servers.
- However, establishing a new TCP connection, negotiating a TLS connection, and authenticating every 5 seconds unnecessarily burdens your application and the mail servers.
Using the IMAP IDLE command
The IMAP IDLE command is fully supported by Infomaniak's email servers.
Rather than regularly querying the server (polling), it is strongly recommended to use IDLE (RFC 2177) for applications that need to react quickly to the arrival of new messages, for example, an automation script or an IMAP bridge to MQTT.
- Single connection: the client opens a secure IMAP connection and keeps it in a waiting state.
- Fast response: the server reports changes in the mailbox, including the arrival of new messages.
- Reduced resource usage: this avoids repeated connections and authentications.
Best practices for IMAP applications
An application using IDLE must be able to handle network outages, disconnections, and any potential service interruptions.
Managing Interruptions and Disconnections
An internet connection can be interrupted without warning, particularly due to a network issue, router, or firewall.
- Implement a mechanism to detect when a connection is no longer active.
- In case of disconnection, properly close the session and initiate a new connection attempt.
Regularly renew the IDLE session
An IDLE session should not be maintained indefinitely. The client must periodically exit and then restart the IDLE command.
- Renew the
IDLEcommand at the latest every 29 minutes, in accordance with the protocol recommendations. - This renewal also allows you to verify that the connection is still working.
Plan for a gradual reconnection
In the event of a network outage or temporary server unavailability:
- Avoid attempting continuous reconnections.
- Use an increasing delay between attempts (e.g., 5 s, 10 s, 30 s, then 1 min).
Retrieve messages after a disconnection
Messages may have been received during the disconnection period. After each successful reconnection, perform a check for any received or unread messages before switching back to IDLE mode.
Link naar deze veelgestelde vragen: https://faq.infomaniak.com/136
Is deze veelgestelde vragenlijst nuttig geweest?