port: feat(notifications): allow SMTP without authentication (upstream #4844) - #165
Merged
Conversation
Some SMTP relays (e.g. Google SMTP Relay with IP allowlisting) do not use username/password authentication. Make both fields optional in the email notification form and API schema, and only pass auth to nodemailer when credentials are provided. Ported from upstream Dokploy#4844 (closes upstream Dokploy#4842). No migration: upstream keeps the notification table's username/password columns NOT NULL and relaxes only the zod apiCreateEmail schema; the form coerces empty inputs to "" (data.username || ""), and an empty string satisfies NOT NULL, so no column constraint change is required.
Add a self-contained unit test asserting that the nodemailer transport receives the `auth` option only when both a username and a password are present, covering the empty/undefined/partial-credential cases behind the "SMTP without authentication" change.
Drop NOT NULL on the email table's username/password columns so the "SMTP without authentication" feature can persist genuinely empty credentials, and add migration 0192 (idempotent ALTER ... DROP NOT NULL, additive-relaxing) in the next free journal slot after 0191. Upstream Dokploy#4844 kept the columns NOT NULL and coerced the form to ""; this fork makes the schema match the relaxed intent so credential-less SMTP relays are represented as NULL rather than empty strings. Loading an existing email notification coerces the now-nullable username/password to undefined for the form.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ports upstream Dokploy/dokploy#4844 by @hbilal9 into the fork (upstream closes Dokploy#4842).
Problem
Some SMTP relays (e.g. Google SMTP Relay with IP allowlisting) do not use username/password authentication, but the email notification form and API required both, and
sendEmailNotificationalways passedauth: { user, pass }to nodemailer.Fix (from upstream, applied verbatim)
handle-notifications.tsx: formnotificationSchemamakesusername/passwordoptional, the fields show an "Optional. Leave blank if your SMTP server does not require authentication." description and a null-safevalue, and the create/test payloads coerce todata.username || "".packages/server/src/db/schema/notification.ts: theapiCreateEmailzod schema relaxesusername/passwordfromz.string().min(1)toz.string().packages/server/src/utils/notifications/utils.ts: nodemailer only receivesauthwhen both credentials are present (...(username && password ? { auth } : {})).Migration (fork addition beyond upstream)
Upstream keeps the
emailtable'susername/passwordcolumnsNOT NULLand relies on empty-string coercion. This fork goes further so the schema faithfully represents credential-less relays:.notNull()onemail.username/email.passwordin the drizzle schema.0192_futuristic_texas_twister.sqlin the next free journal slot after0191(idx 192,whenstrictly greater than the previous entry), LF line endings per.gitattributes. It is additive-relaxing and idempotent:_journal.json+0192_snapshot.jsonregenerated bydrizzle-kit generate(no unrelated drift — only the two DROP NOT NULL statements).emailtype is now nullable, the edit form coercesnotification.email?.username/passwordtoundefinedwhen resetting.Adaptation
Added a small self-contained unit test (
__test__/notifications/email-auth.test.ts, authored separately) assertingauthis included only when both credentials are non-empty (empty/undefined/partial cases covered), following the fork's existing contract-mirroring test pattern. Upstream shipped no test.Verification
pnpm --filter=dokploy typecheckandpnpm --filter=@dokploy/server typecheck— both clean.pnpm exec vitest __test__/notifications/email-auth.test.ts --run— 5 passed.drizzle-kit generate; snapshot/journal consistent, LF-only.Credit: @hbilal9 (upstream Dokploy#4844).