Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(server): Support for SMTP-over-TLS #1856

Merged
merged 1 commit into from Apr 9, 2024

Conversation

WangZhiYao
Copy link
Contributor

As per the code restriction specified in the configuration schema, the SMTP_URL was required to start with smtp://.

SMTP_URL: z.string().url().startsWith("smtp://").optional(),

However, my email service provider utilizes SSL on port 465. Despite attempting various configurations based on the nodemailer documentation available here, I encountered difficulties in sending emails through the SMTP service using the following settings:

smtp://username:password@smtp.example.com:465
smtp://username:password@smtp.example.com:465/?secure=true
smtp://username:password@smtp.example.com:587/?requireTLS=true

Upon further investigation, I found that nodemailer supports the smtps:// protocol. Consequently, I have updated the validation in zod to permit the SMTP_URL configuration to start with smtps://. This adjustment now enables me to utilize the following configuration for sending emails via SMTP of my email service provider:

smtps://username:password@smtp.example.com:465

So I made this pull request, hoping to help people who have the same problem as me.

@AmruthPillai
Copy link
Owner

Seems like a valid PR, although the validation check could just be simplified to .startsWith("smtp") because it would include both smtp and smtps.

@WangZhiYao
Copy link
Contributor Author

WangZhiYao commented Apr 9, 2024

Seems like a valid PR, although the validation check could just be simplified to .startsWith("smtp") because it would include both smtp and smtps.

If change this to startsWith("smtp") instead of fully qualifying it as the protocol schema, then smtp+tls:// will also pass the validation check but nodemailer does not seem to support such a protocol, this may cause some other confusions, so I don't recommend for this.

@AmruthPillai
Copy link
Owner

Agreed, looks good to me! :)

@AmruthPillai AmruthPillai merged commit dd97c6d into AmruthPillai:main Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants