diff --git a/backend/src/plugins/core/admin/email/mail.service.ts b/backend/src/plugins/core/admin/email/mail.service.ts index 9ca8273c6..b035759a7 100644 --- a/backend/src/plugins/core/admin/email/mail.service.ts +++ b/backend/src/plugins/core/admin/email/mail.service.ts @@ -28,6 +28,19 @@ export class MailService { private readonly transporter: nodemailer.Transporter; constructor() { + if (!fs.existsSync(this.path)) { + // Create a default config file + fs.writeFileSync( + this.path, + JSON.stringify({ + smtp_host: "", + smtp_user: "", + smtp_secure: false, + smtp_port: 587 + }) + ); + } + const data = fs.readFileSync(this.path, "utf-8"); const config: ShowAdminEmailSettingsServiceObjWithPassword = JSON.parse(data); diff --git a/backend/src/plugins/core/admin/email/settings/show/show.service.ts b/backend/src/plugins/core/admin/email/settings/show/show.service.ts index f4077fbda..f60c04158 100644 --- a/backend/src/plugins/core/admin/email/settings/show/show.service.ts +++ b/backend/src/plugins/core/admin/email/settings/show/show.service.ts @@ -14,16 +14,6 @@ export class ShowAdminEmailSettingsService extends HelpersAdminEmailSettingsServ settings: { email: emailSettings } } = getConfigFile(); - if (!fs.existsSync(this.path)) { - return { - smtp_host: "", - smtp_user: "", - smtp_secure: false, - smtp_port: 587, - ...emailSettings - }; - } - const read = fs.readFileSync(this.path, "utf-8"); const config: ShowAdminEmailSettingsServiceObj = JSON.parse(read);