[Bug]: Appsmith shouldn't attempt to STARTTLS if TLS is disabled in the config.
Is there an existing issue for this?
- [X] I have searched the existing issues
Description
When starting a server that has TLS disabled in the config, it will attempt STARTTLS anyway.
I expect the server to not try STARTTLS if TLS is disabled.
Steps To Reproduce
- Disable TLS in your instance config.
- Start your instance and watch the logs.
- Observer that STARTTLS is logged anyway.
Public Sample App
No response
Issue video log
No response
Version
1.9.7
I think what could solve this is to try the following:
In EnvManagerCEImpl.java around line 700 to move the line props.put("mail.smtp.starttls.enable", "true"); into the following if-else clause.
Properties props = mailSender.getJavaMailProperties();
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.timeout", 7000); // 7 seconds
if (StringUtils.hasLength(requestDTO.getUsername())) {
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.auth", "true");
mailSender.setUsername(requestDTO.getUsername());
mailSender.setPassword(requestDTO.getPassword());
} else {
props.put("mail.smtp.starttls.enable", "false");
props.put("mail.smtp.auth", "false");
}
props.put("mail.debug", "true");
This way starttls is only true when the TLS option is checked in the test mail form.
@degude, indeed. Thanks for suggesting. We actually have a PR regarding that at #17952, but that was doing a little too much, which was causing problems in merging. I think I'll tone that PR back and only solve this one problem so it can finally go in.
I'll take this up. Thanks!
It works like a charm now, thank you guys ❤️