Hello @visionik,
Context
While testing IMAP and SMTP with iCloud.com email accounts, I noticed a difference in behavior between the two protocols.
IMAP works out of the box without any additional configuration. However, SMTP fails when the client attempts to establish a connection using DialTLS.
The failure occurs at:
internal/smtp/client.go:218
At this point, the code attempts a direct TLS connection, which triggers an error flow. In contrast, when using STARTTLS, the connection to the iCloud.com SMTP server succeeds and email delivery works as expected.
Analysis
This behavior suggests that, for iCloud.com, direct TLS SMTP connections are not consistently supported in the same way as STARTTLS. While both are valid SMTP security mechanisms, they are not interchangeable in practice across all providers.
Proposal
Add support for a fallback mechanism when both TLS and STARTTLS are enabled in the configuration.
Example:
Proposed behavior:
- Attempt a direct TLS connection (
DialTLS)
- If it fails, automatically fall back to STARTTLS
Question
Are there any architectural or design constraints in the project that would prevent or discourage implementing this fallback strategy? If not, I can open a PR implementing this behavior.
Hello @visionik,
Context
While testing IMAP and SMTP with iCloud.com email accounts, I noticed a difference in behavior between the two protocols.
IMAP works out of the box without any additional configuration. However, SMTP fails when the client attempts to establish a connection using
DialTLS.The failure occurs at:
At this point, the code attempts a direct TLS connection, which triggers an error flow. In contrast, when using STARTTLS, the connection to the iCloud.com SMTP server succeeds and email delivery works as expected.
Analysis
This behavior suggests that, for iCloud.com, direct TLS SMTP connections are not consistently supported in the same way as STARTTLS. While both are valid SMTP security mechanisms, they are not interchangeable in practice across all providers.
Proposal
Add support for a fallback mechanism when both TLS and STARTTLS are enabled in the configuration.
Example:
{ "accounts": { "someone@icloud.com": { "smtp": { "tls": true, "starttls": true } } } }Proposed behavior:
DialTLS)Question
Are there any architectural or design constraints in the project that would prevent or discourage implementing this fallback strategy? If not, I can open a PR implementing this behavior.