You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add IMAP STARTTLS support with RFC 8314 security enum
Replace ambiguous use_ssl/start_ssl boolean pair with a clean
ConnectionSecurity enum (tls/starttls/none) per RFC 8314.
Changes:
- Add ConnectionSecurity enum to config.py
- Add model_validator for backward compat with use_ssl/start_ssl
- Implement IMAP STARTTLS transport upgrade via asyncio.loop.start_tls()
- Add _create_imap_connection() factory for TLS/STARTTLS/plaintext
- Add IMAP verify_ssl support for self-signed certificates
- Wire SMTP flags from security enum in EmailClient
- Add MCP_EMAIL_SERVER_IMAP_SECURITY/SMTP_SECURITY env vars
- Update existing tests to use _connect_imap instead of imap_class
- Add comprehensive tests for new security features
- Update README with security modes, env vars, and ProtonMail Bridge example
Existing configs with use_ssl/start_ssl continue to work unchanged.
The start_ssl field was previously ignored for IMAP — this fixes that.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|`MCP_EMAIL_SERVER_IMAP_HOST`| IMAP server host | - | Yes |
74
74
|`MCP_EMAIL_SERVER_IMAP_PORT`| IMAP server port |`993`| No |
75
-
|`MCP_EMAIL_SERVER_IMAP_SSL`| Enable IMAP SSL |`true`| No |
75
+
|`MCP_EMAIL_SERVER_IMAP_SECURITY`| IMAP connection security: `tls`, `starttls`, or `none`|`tls`| No |
76
+
|`MCP_EMAIL_SERVER_IMAP_VERIFY_SSL`| Verify IMAP SSL certificates |`true`| No |
76
77
|`MCP_EMAIL_SERVER_SMTP_HOST`| SMTP server host | - | Yes |
77
78
|`MCP_EMAIL_SERVER_SMTP_PORT`| SMTP server port |`465`| No |
78
-
|`MCP_EMAIL_SERVER_SMTP_SSL`| Enable SMTP SSL |`true`| No |
79
-
|`MCP_EMAIL_SERVER_SMTP_START_SSL`| Enable STARTTLS |`false`| No |
80
-
|`MCP_EMAIL_SERVER_SMTP_VERIFY_SSL`| Verify SSL certificates (disable for self-signed) |`true`| No |
79
+
|`MCP_EMAIL_SERVER_SMTP_SECURITY`| SMTP connection security: `tls`, `starttls`, or `none`|`tls`| No |
80
+
|`MCP_EMAIL_SERVER_SMTP_VERIFY_SSL`| Verify SMTP SSL certificates |`true`| No |
81
81
|`MCP_EMAIL_SERVER_ENABLE_ATTACHMENT_DOWNLOAD`| Enable attachment download |`false`| No |
82
82
|`MCP_EMAIL_SERVER_SAVE_TO_SENT`| Save sent emails to IMAP Sent folder |`true`| No |
83
83
|`MCP_EMAIL_SERVER_SENT_FOLDER_NAME`| Custom Sent folder name (auto-detect if not set) | - | No |
84
84
85
+
> **Deprecated:**`MCP_EMAIL_SERVER_IMAP_SSL`, `MCP_EMAIL_SERVER_SMTP_SSL`, and `MCP_EMAIL_SERVER_SMTP_START_SSL` still work for backward compatibility but are superseded by the `*_SECURITY` variables above.
86
+
87
+
#### Connection Security Modes
88
+
89
+
The `security` field (or `*_SECURITY` env var) controls how the connection to the mail server is encrypted, per [RFC 8314](https://tools.ietf.org/html/rfc8314):
If you're using a local mail server with self-signed certificates (like ProtonMail Bridge), you'll need to disable SSL certificate verification:
168
+
If you're using a local mail server with self-signed certificates (like ProtonMail Bridge), you'll need to disable SSL certificate verification for both IMAP and SMTP:
157
169
158
170
```json
159
171
{
@@ -162,6 +174,7 @@ If you're using a local mail server with self-signed certificates (like ProtonMa
162
174
"command": "uvx",
163
175
"args": ["mcp-email-server@latest", "stdio"],
164
176
"env": {
177
+
"MCP_EMAIL_SERVER_IMAP_VERIFY_SSL": "false",
165
178
"MCP_EMAIL_SERVER_SMTP_VERIFY_SSL": "false"
166
179
}
167
180
}
@@ -176,7 +189,37 @@ Or in TOML configuration:
176
189
account_name = "protonmail"
177
190
# ... other settings ...
178
191
192
+
[emails.incoming]
193
+
verify_ssl = false
194
+
195
+
[emails.outgoing]
196
+
verify_ssl = false
197
+
```
198
+
199
+
#### ProtonMail Bridge Example
200
+
201
+
ProtonMail Bridge uses STARTTLS on local ports with self-signed certificates:
0 commit comments