diff --git a/apps/dokploy/components/dashboard/settings/notifications/handle-notifications.tsx b/apps/dokploy/components/dashboard/settings/notifications/handle-notifications.tsx
index d4abdc63b..cad1d5d1b 100644
--- a/apps/dokploy/components/dashboard/settings/notifications/handle-notifications.tsx
+++ b/apps/dokploy/components/dashboard/settings/notifications/handle-notifications.tsx
@@ -89,8 +89,8 @@ export const notificationSchema = z.discriminatedUnion("type", [
type: z.literal("email"),
smtpServer: z.string().min(1, { message: "SMTP Server is required" }),
smtpPort: z.number().min(1, { message: "SMTP Port is required" }),
- username: z.string().min(1, { message: "Username is required" }),
- password: z.string().min(1, { message: "Password is required" }),
+ username: z.string().optional(),
+ password: z.string().optional(),
fromAddress: z.string().min(1, { message: "From Address is required" }),
toAddresses: z
.array(
@@ -641,8 +641,8 @@ export const HandleNotifications = ({ notificationId }: Props) => {
volumeBackup: volumeBackup,
smtpServer: data.smtpServer,
smtpPort: data.smtpPort,
- username: data.username,
- password: data.password,
+ username: data.username || "",
+ password: data.password || "",
fromAddress: data.fromAddress,
toAddresses: data.toAddresses,
name: data.name,
@@ -1130,9 +1130,16 @@ export const HandleNotifications = ({ notificationId }: Props) => {
Username
-
+
-
+
+ Optional. Leave blank if your SMTP server does not
+ require authentication.
+
)}
@@ -1149,9 +1156,13 @@ export const HandleNotifications = ({ notificationId }: Props) => {
type="password"
placeholder="******************"
{...field}
+ value={field.value ?? ""}
/>
-
+
+ Optional. Leave blank if your SMTP server does not
+ require authentication.
+
)}
@@ -2043,8 +2054,8 @@ export const HandleNotifications = ({ notificationId }: Props) => {
await testEmailConnection({
smtpServer: data.smtpServer,
smtpPort: data.smtpPort,
- username: data.username,
- password: data.password,
+ username: data.username || "",
+ password: data.password || "",
fromAddress: data.fromAddress,
toAddresses: data.toAddresses,
});
diff --git a/packages/server/src/db/schema/notification.ts b/packages/server/src/db/schema/notification.ts
index 3551f971f..361b18202 100644
--- a/packages/server/src/db/schema/notification.ts
+++ b/packages/server/src/db/schema/notification.ts
@@ -370,8 +370,8 @@ export const apiCreateEmail = notificationsSchema
.extend({
smtpServer: z.string().min(1),
smtpPort: z.number().min(1),
- username: z.string().min(1),
- password: z.string().min(1),
+ username: z.string(),
+ password: z.string(),
fromAddress: z.string().min(1),
toAddresses: z.array(z.string()).min(1),
})
diff --git a/packages/server/src/utils/notifications/utils.ts b/packages/server/src/utils/notifications/utils.ts
index d65258862..add43db28 100644
--- a/packages/server/src/utils/notifications/utils.ts
+++ b/packages/server/src/utils/notifications/utils.ts
@@ -33,7 +33,9 @@ export const sendEmailNotification = async (
const transporter = nodemailer.createTransport({
host: smtpServer,
port: smtpPort,
- auth: { user: username, pass: password },
+ ...(username && password
+ ? { auth: { user: username, pass: password } }
+ : {}),
});
await transporter.sendMail({