Disconnect
Disconnects the client from the mail server.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
info
If ContinueOnError property is true, no error is caught when the project is executed even if Catch node is used.
Input
- Client Id - The unique identifier of the mail client that is used for the connection. The ID is created by the Connect node.
How It Works
The Disconnect node closes the mail server connection and cleans up resources. Here's the process:
- Client ID Validation - Validates Client ID is provided
- Connection Lookup - Finds active connection by Client ID
- IMAP Logout - Executes LOGOUT command to close IMAP connection
- Resource Cleanup - Removes client from active connection pool
- OAuth2 Cleanup - Cleans up OAuth2 resources if applicable
Requirements
- Client ID - Valid Client ID from Connect node (cannot be empty)
Error Handling
| Error Code | Description | Resolution |
|---|---|---|
| Core.Mail.Delete.ErrOnMessage | Message parse error | Check node configuration |
| Core.Mail.Disconnect.Err | Client ID not found | Verify Client ID is valid and connection exists |
Usage Examples
Example 1: Standard Disconnect
// After all mail operations complete
{
"client_id": "{{client_id}}"
}
// Closes connection and frees resources
Example 2: Complete Mail Workflow
// 1. Connect to mail server
// Output: client_id
// 2. Get/Search/Send emails using client_id
// ... mail operations ...
// 3. Always disconnect at the end
// Input: client_id
// Ensures proper cleanup
Example 3: Error Handling with Disconnect
try {
// Connect
var clientId = {{client_id}};
// Perform mail operations
// ...
} catch (error) {
console.log("Error:", error);
} finally {
// Always disconnect, even if error occurs
// Use Disconnect node with clientId
}
Usage Notes
- Always Disconnect: Always use Disconnect at end of mail workflows
- Resource Management: Prevents connection leaks and frees server resources
- One Per Connect: Each Connect requires corresponding Disconnect
- Automatic Cleanup: Connections are auto-cleaned on flow end, but explicit disconnect is best practice
- Multiple Connections: If using multiple Connect nodes, disconnect each one
- OAuth2 Cleanup: Automatically cleans up OAuth2 browser windows and tokens
Tips
- Use Finally Blocks: Place Disconnect in Finally block to ensure it always executes
- Clean Workflow End: Always end mail workflows with Disconnect
- Error Recovery: Disconnect even if errors occur during mail operations
- Performance: Disconnecting frees server resources for other users
- Connection Pooling: Don't reuse Client IDs across different flow executions
Related Nodes
- Connect - Establishes connection (creates Client ID)
- All other mail nodes - Use the Client ID created by Connect