Skip to content

port: feat(notifications): allow SMTP without authentication (upstream #4844) - #165

Merged
AminDhouib merged 3 commits into
canaryfrom
port/upr-4844
Jul 18, 2026
Merged

port: feat(notifications): allow SMTP without authentication (upstream #4844)#165
AminDhouib merged 3 commits into
canaryfrom
port/upr-4844

Conversation

@AminDhouib

@AminDhouib AminDhouib commented Jul 18, 2026

Copy link
Copy Markdown
Member

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 sendEmailNotification always passed auth: { user, pass } to nodemailer.

Fix (from upstream, applied verbatim)

  • handle-notifications.tsx: form notificationSchema makes username/password optional, the fields show an "Optional. Leave blank if your SMTP server does not require authentication." description and a null-safe value, and the create/test payloads coerce to data.username || "".
  • packages/server/src/db/schema/notification.ts: the apiCreateEmail zod schema relaxes username/password from z.string().min(1) to z.string().
  • packages/server/src/utils/notifications/utils.ts: nodemailer only receives auth when both credentials are present (...(username && password ? { auth } : {})).

Migration (fork addition beyond upstream)

Upstream keeps the email table's username/password columns NOT NULL and relies on empty-string coercion. This fork goes further so the schema faithfully represents credential-less relays:

  • Drops .notNull() on email.username / email.password in the drizzle schema.
  • Adds migration 0192_futuristic_texas_twister.sql in the next free journal slot after 0191 (idx 192, when strictly greater than the previous entry), LF line endings per .gitattributes. It is additive-relaxing and idempotent:
    ALTER TABLE "email" ALTER COLUMN "username" DROP NOT NULL;
    ALTER TABLE "email" ALTER COLUMN "password" DROP NOT NULL;
  • Meta _journal.json + 0192_snapshot.json regenerated by drizzle-kit generate (no unrelated drift — only the two DROP NOT NULL statements).
  • Because the loaded email type is now nullable, the edit form coerces notification.email?.username/password to undefined when resetting.

Adaptation

Added a small self-contained unit test (__test__/notifications/email-auth.test.ts, authored separately) asserting auth is 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 typecheck and pnpm --filter=@dokploy/server typecheck — both clean.
  • pnpm exec vitest __test__/notifications/email-auth.test.ts --run5 passed.
  • Migration generated via drizzle-kit generate; snapshot/journal consistent, LF-only.

Credit: @hbilal9 (upstream Dokploy#4844).

hbilal9 and others added 3 commits July 18, 2026 03:22
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.
@AminDhouib
AminDhouib merged commit cd8a793 into canary Jul 18, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow empty username and password for SMTP

2 participants