This commit is contained in:
HBilal Khan Yousafzai 2026-09-11 13:11:52 -04:00 committed by GitHub
commit 4e4b7d2440
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 25 additions and 12 deletions

View File

@ -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) => {
<FormItem className="w-full">
<FormLabel>Username</FormLabel>
<FormControl>
<Input placeholder="username" {...field} />
<Input
placeholder="username"
{...field}
value={field.value ?? ""}
/>
</FormControl>
<FormDescription>
Optional. Leave blank if your SMTP server does not
require authentication.
</FormDescription>
<FormMessage />
</FormItem>
)}
@ -1149,9 +1156,13 @@ export const HandleNotifications = ({ notificationId }: Props) => {
type="password"
placeholder="******************"
{...field}
value={field.value ?? ""}
/>
</FormControl>
<FormDescription>
Optional. Leave blank if your SMTP server does not
require authentication.
</FormDescription>
<FormMessage />
</FormItem>
)}
@ -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,
});

View File

@ -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),
})

View File

@ -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({