feat: add MAILER_SMTP_IGNORE_TLS and optional SMTP auth#5972
feat: add MAILER_SMTP_IGNORE_TLS and optional SMTP auth#5972jamesgeorge007 merged 10 commits intonextfrom
MAILER_SMTP_IGNORE_TLS and optional SMTP auth#5972Conversation
There was a problem hiding this comment.
Pull request overview
This PR enhances the backend SMTP mailer configuration to support optional SMTP authentication credentials and introduces a new MAILER_SMTP_IGNORE_TLS infra config flag, with onboarding/admin flows updated accordingly.
Changes:
- Added
MAILER_SMTP_IGNORE_TLSto infra config enums, defaults, and boolean validation. - Made advanced SMTP
authoptional when username/password are not provided. - Updated onboarding DTOs to include the new SMTP flag.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/hoppscotch-backend/src/types/InfraConfig.ts | Adds the new infra config enum entry for MAILER_SMTP_IGNORE_TLS. |
| packages/hoppscotch-backend/src/mailer/helper.ts | Makes SMTP auth optional and wires ignoreTLS into the transport options. |
| packages/hoppscotch-backend/src/infra-config/infra-config.service.ts | Removes SMTP user/password from “configured” checks and adds boolean validation for the new key. |
| packages/hoppscotch-backend/src/infra-config/helper.ts | Removes auth keys from required list and adds a default value for MAILER_SMTP_IGNORE_TLS. |
| packages/hoppscotch-backend/src/infra-config/dto/onboarding.dto.ts | Adds request/response fields for MAILER_SMTP_IGNORE_TLS. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
1 issue found across 5 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/hoppscotch-backend/src/mailer/helper.ts">
<violation number="1" location="packages/hoppscotch-backend/src/mailer/helper.ts:29">
P2: Validate SMTP auth as all-or-nothing with non-empty trimmed values; the current logic can emit `auth` with an empty username or password.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Greptile SummaryThis PR adds Key changes:
Issues found:
Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant UI as Admin UI / Onboarding
participant FE as useConfigHandler / useOnboardingConfigHandler
participant GQL as GraphQL / REST API
participant SVC as InfraConfigService
participant DB as Database
participant ML as Mailer (nodemailer)
UI->>FE: User submits SMTP config
FE->>FE: hasPartialSmtpCredentials() check
Note over FE: !! smtpUser !== !! smtpPass → toast error
FE->>GQL: updateInfraConfigs([...fields])
GQL->>SVC: updateMany(infraConfigs)
SVC->>SVC: validateEnvValues() — type/format checks
SVC->>DB: Query missing credential from DB
DB-->>SVC: Encrypted / plain value
SVC->>SVC: validateSmtpCredentialPair()<br/>hasUser !== hasPass → INVALID_INPUT
SVC->>DB: Transaction: upsert all fields
SVC->>SVC: stopApp() — reload env
SVC-->>GQL: E.right(configs)
GQL-->>UI: Success
Note over ML: On app restart
ML->>SVC: getTransportOption(env)
SVC->>ML: smtpUser && smtpPass → auth: {user, pass}
Note over ML: MAILER_SMTP_IGNORE_TLS=true → ignoreTLS:true<br/>(no-op when secure:true)
ML-->>ML: Transport ready
|
There was a problem hiding this comment.
1 issue found across 6 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/hoppscotch-sh-admin/src/composables/useOnboardingConfigHandler.ts">
<violation number="1" location="packages/hoppscotch-sh-admin/src/composables/useOnboardingConfigHandler.ts:260">
P2: SMTP auth validation now allows partial credentials (username without password, or vice versa). Require both fields together or neither to avoid invalid SMTP auth payloads passing onboarding validation.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
packages/hoppscotch-sh-admin/src/composables/useOnboardingConfigHandler.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
packages/hoppscotch-sh-admin/src/composables/useConfigHandler.ts:287
- With SMTP auth now optional, the empty-field check excludes
mailer_smtp_userandmailer_smtp_password, but there’s still no guard against saving only one of them. This can leave the instance in a partially-authenticated state that will fail when the backend constructs the SMTP transport. Add a validation rule for the email section to ensure user+password are either both non-empty (after trimming) or both empty before allowing save.
if (section.name === 'email') {
const { mailer_use_custom_configs, ...otherFields } = section.fields;
// mailer_smtp_user and mailer_smtp_password are always optional (auth is optional)
const optionalMailerKeys = ['mailer_smtp_user', 'mailer_smtp_password'];
const excludeKeys = mailer_use_custom_configs
? ['mailer_smtp_url', ...optionalMailerKeys]
: [
'mailer_smtp_host',
'mailer_smtp_port',
'mailer_smtp_user',
'mailer_smtp_password',
];
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/hoppscotch-sh-admin/src/composables/useOnboardingConfigHandler.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/hoppscotch-sh-admin/src/components/onboarding/SmtpSetup.vue
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/hoppscotch-sh-admin/src/composables/useOnboardingConfigHandler.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
packages/hoppscotch-sh-admin/src/composables/useConfigHandler.ts:287
optionalMailerKeysis introduced to mark SMTP user/password as optional, but theexcludeKeysconstruction still hardcodes those keys again in the non-custom branch. This duplication makes it easy for the optional/required logic to drift over time. Consider reusingoptionalMailerKeysin both branches (or using a Set) to keep the validation rules consistent and maintainable.
// SMTP user and password are fully optional (can be blank individually or both)
const optionalMailerKeys = ['mailer_smtp_user', 'mailer_smtp_password'];
const excludeKeys = mailer_use_custom_configs
? ['mailer_smtp_url', ...optionalMailerKeys]
: [
'mailer_smtp_host',
'mailer_smtp_port',
'mailer_smtp_user',
'mailer_smtp_password',
];
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Relax SMTP auth handling by no longer throwing errors when either MAILER_SMTP_USER or MAILER_SMTP_PASSWORD is missing. The auth object is now built only with provided fields using conditional spreads, and unused error imports were removed. This simplifies and makes SMTP configuration more flexible for providers that accept partial credentials.
Validate SMTP username and password as a pair across the backend write path, transport construction, and both admin UI flows. Onboarding check is scoped to custom SMTP mode to avoid blocking on stale fields after toggling.
d237dce to
99c8d96
Compare
Closes BE-714 FE-1169
What's changed
This PR makes SMTP authentication optional for deployments that use unauthenticated relay servers (e.g., internal mail relays, local dev tools like Mailpit).
MAILER_SMTP_USERandMAILER_SMTP_PASSWORDare now optional as a pair. Both can be left empty for unauthenticated SMTP, but partial credentials (only one of the two) are rejected at the backend write path, runtime transport construction, and both admin UI flows (onboarding and settings).MAILER_SMTP_IGNORE_TLSfor SMTP servers that do not support STARTTLS.The onboarding UI and the Admin SMTP configuration tab have been updated to reflect these changes.
Notes to reviewers
The both-or-neither credential constraint is enforced at four layers: backend effective-state validation before DB write, runtime transport construction, admin settings save, and onboarding submission. The onboarding check is scoped to custom SMTP mode so stale fields from toggling between URL and custom mode do not block unrelated submissions.
<!-- This is an auto-generated description by cubic. -->
Summary by cubic
Make SMTP auth optional and add
MAILER_SMTP_IGNORE_TLSso unauthenticated or no‑TLS SMTP works. Updates onboarding/Admin SMTP UIs, defaults, and validation; enforces both‑or‑neither credentials. Closes BE-714, FE-1169.authonly when bothMAILER_SMTP_USERandMAILER_SMTP_PASSWORDare set; fields are optional in onboarding/Admin and can be cleared to remove saved creds; both-or-neither is enforced in the backend and UIs with an error message.MAILER_SMTP_IGNORE_TLS(defaultfalse) mapped to transportignoreTLS; included in defaults, validation, DTOs/types, and both SMTP config UIs with i18n labels and a checkbox.Written for commit 99c8d96. Summary will update on new commits.
<!-- End of auto-generated description by cubic. -->