-
Notifications
You must be signed in to change notification settings - Fork 336
feat(labrinth): environment variables for more customizable SMTP #2886
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
Conversation
This will help setting up labrinth for local development. You can now use a mock SMTP server such as smtp4dev. The TLS options will stay the same as before if set to `true`, and disabled when `false`. Depends on modrinth#2883
Prioritizing this over #2883, making that one a draft and removing dependency on it due to conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR addresses a real issue and is looking great overall, thank you! I'd like to take stewardship of it and work toward getting it merged soon. @Erb3, could you please update the branch and take a look at the comments below?
Co-authored-by: AlexTMjugador<me@alegon.dev> Co-authored-by: Alejandro González <7822554+AlexTMjugador@users.noreply.github.com> Signed-off-by: Erb3 <49862976+Erb3@users.noreply.github.com>
Signed-off-by: Erb3 <49862976+Erb3@users.noreply.github.com>
Replaced if/else with a switch statement. The new values for `SMPT_TLS` are `none`, `opportunistic_start_tls`, `requires_start_tls`, `tls`. When none of these values are supplied, it defaults to full TLS (`tls`), and throws a warning. Resolves PR review
Signed-off-by: Erb3 <49862976+Erb3@users.noreply.github.com>
Good catches, I've updated the code. The default port is 465, and can be modified with
If none of these values are supplied to I have not tested the code with TLS as I don't have an email server. The SMTP_USERNAME=modrinth
SMTP_PASSWORD=frog
SMTP_HOST=localhost
SMTP_PORT=2525
SMTP_TLS=none Thank you for your very friendly review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Splendid, thank you for your thoughtful PR and comments!
I've tested this on my end with Mailtrap’s STARTTLS-enabled SMTP development server, and everything worked great. It's also trivially clear that the direct TLS case has to function as expected, so we now have full coverage of all practical SMTP transport layer security protocols.
Would you be up for tweaking one last thing before merging?
Co-authored-by: Alejandro González <7822554+AlexTMjugador@users.noreply.github.com> Signed-off-by: Erb3 <49862976+Erb3@users.noreply.github.com>
This pull request adds two new environment variables,
SMTP_PORT
andSMTP_TLS
. SMTP refers the protocol used to send emails.SMTP_PORT
configures which port to connect to on the SMTP server. It defaults to the standard and old default,465
.SMTP_TLS
is a boolean that defines if TLS security should be required to connect to the server. This defaults to the old value,true
. Implementation wise I've copied the default values from thelettre
crate we are using if the setting is enabled. This is how it behaved before, as we did not specify a TLS setting. If it is set tofalse
it will instead useTls::None
.This will help setting up labrinth for local development. You can use a mock SMTP server such as smtp4dev without setting up certificates and such.