allow setting secure for smtp in config
This commit is contained in:
parent
61b34c8b16
commit
fdb1ab4bd9
2 changed files with 14 additions and 18 deletions
|
@ -6,26 +6,21 @@ import logger from "@server/logger";
|
||||||
|
|
||||||
function createEmailClient() {
|
function createEmailClient() {
|
||||||
const emailConfig = config.getRawConfig().email;
|
const emailConfig = config.getRawConfig().email;
|
||||||
if (
|
if (!emailConfig || !emailConfig.no_reply) {
|
||||||
!emailConfig?.smtp_host ||
|
logger.warn(
|
||||||
!emailConfig?.smtp_pass ||
|
"Email SMTP configuration is missing. Emails will not be sent."
|
||||||
!emailConfig?.smtp_port ||
|
);
|
||||||
!emailConfig?.smtp_user
|
return;
|
||||||
) {
|
}
|
||||||
logger.warn(
|
|
||||||
"Email SMTP configuration is missing. Emails will not be sent.",
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
return nodemailer.createTransport({
|
return nodemailer.createTransport({
|
||||||
host: emailConfig.smtp_host,
|
host: emailConfig.smtp_host,
|
||||||
port: emailConfig.smtp_port,
|
port: emailConfig.smtp_port,
|
||||||
secure: false,
|
secure: emailConfig.smtp_secure || false,
|
||||||
auth: {
|
auth: {
|
||||||
user: emailConfig.smtp_user,
|
user: emailConfig.smtp_user,
|
||||||
pass: emailConfig.smtp_pass,
|
pass: emailConfig.smtp_pass
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,10 +122,11 @@ const configSchema = z.object({
|
||||||
}),
|
}),
|
||||||
email: z
|
email: z
|
||||||
.object({
|
.object({
|
||||||
smtp_host: z.string(),
|
smtp_host: z.string().optional(),
|
||||||
smtp_port: portSchema,
|
smtp_port: portSchema.optional(),
|
||||||
smtp_user: z.string(),
|
smtp_user: z.string().optional(),
|
||||||
smtp_pass: z.string(),
|
smtp_pass: z.string().optional(),
|
||||||
|
smtp_secure: z.boolean().optional(),
|
||||||
no_reply: z.string().email()
|
no_reply: z.string().email()
|
||||||
})
|
})
|
||||||
.optional(),
|
.optional(),
|
||||||
|
|
Loading…
Add table
Reference in a new issue