PromucFlow_constructor/app/server/appsmith-plugins/smtpPlugin/src
Nilansh Bansal 0eb5939cc9
fix: fixed smtp code to add starttls disabled if credentials are not provided (#40005)
## Background
[This PR](https://github.com/appsmithorg/appsmith/pull/37319) updated
the SMTP datasource in Appsmith to support configurations without
requiring a username and password. However, it inadvertently enforced
the `mail.smtp.starttls.enable` property even when credentials were not
provided. This led to an issue where STARTTLS was unnecessarily
enforced, causing problems for users configuring SMTP without
authentication, as detailed in [this
issue](https://github.com/appsmithorg/appsmith/issues/39965).


## Description
This PR resolves the issue by ensuring that the starttls and auth
properties are only set when a username and password are provided. This
change allows the SMTP datasource to function correctly without
authentication, aligning with user expectations and preventing
unnecessary STARTTLS enforcement.

Fixes #39965 

## Automation

/ok-to-test tags="@tag.Datasource"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/14192755822>
> Commit: 7334f48a5678490cb1468b4f6460546e7496a3cc
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=14192755822&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Datasource`
> Spec:
> <hr>Tue, 01 Apr 2025 10:42:30 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Bug Fixes**
- Improved the email configuration experience by ensuring that security
settings for authentication and encrypted connections are applied only
when valid credentials are provided, resulting in more reliable behavior
for both authenticated and non-authenticated email server setups.
- Enhanced validation in tests to confirm that session properties
reflect the correct settings based on authentication presence.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-04-01 16:49:14 +05:30
..
main fix: fixed smtp code to add starttls disabled if credentials are not provided (#40005) 2025-04-01 16:49:14 +05:30
test/java/com/external/plugins fix: fixed smtp code to add starttls disabled if credentials are not provided (#40005) 2025-04-01 16:49:14 +05:30