Add support for **Implicit TLS (SMTPS)** to the SMTP email service#1554
Open
hungtcs wants to merge 1 commit into
Open
Add support for **Implicit TLS (SMTPS)** to the SMTP email service#1554hungtcs wants to merge 1 commit into
hungtcs wants to merge 1 commit into
Conversation
- Add EMAIL_SMTP_ENABLE_IMPLICIT_TLS config variable to replace hardcoded port check - Send function now uses the config flag to establish TLS before any SMTP command - Skip STARTTLS when implicit TLS is active
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The SMTP
Sendfunction only supported STARTTLS (plain connection → STARTTLS command → TLS upgrade), which works on ports like 587.However, many SMTP servers — including Aliyun DirectMail — use port 465 with Implicit TLS (TLS handshake before any SMTP command).
The original code attempted a plain TCP connection on port 465, causing the server to reject it immediately with
EOF.Changes
app/pkg/env/env.goEMAIL_SMTP_ENABLE_IMPLICIT_TLS(default:false)app/services/email/smtp/smtp.goSendfunction now accepts anenableImplicitTLS boolparametertls.Dial) before any SMTP dialogue, then creates the SMTP client viasmtp.NewClientsmtp.Dial+ STARTTLS flowapp/services/email/smtp/smtp_test.gomockSendsignature to match the newSendfunction signatureUsage
Add to
.env: