diff --git a/utils/data/configs.js b/utils/data/configs.js index 86454cb..4abbfc4 100644 --- a/utils/data/configs.js +++ b/utils/data/configs.js @@ -228,7 +228,7 @@ export default class ProjectConfigs { configs.custom_template.enabled = customTemplateEnabled === 'on' ?? false; // mail configurations - configs.mail = [...email.map(({batch_size, delay_per_batch, auth_user, auth_pass, ...rest}) => { + configs.mail = [...email.map(({batch_size, delay_per_batch, auth_user, auth_pass, secure, ...rest}) => { return { ...rest, batch_size: parseInt(batch_size), @@ -236,7 +236,8 @@ export default class ProjectConfigs { auth: { user: auth_user, pass: auth_pass - } + }, + secure: secure === 'on' ? true : false }; })]; @@ -311,4 +312,4 @@ export default class ProjectConfigs { this.ghoslerVersion = JSON.parse(fileContent).version; }).catch((_) => this.ghoslerVersion = ''); } -} \ No newline at end of file +} diff --git a/utils/mail/mailer.js b/utils/mail/mailer.js index ac68100..7d4063a 100644 --- a/utils/mail/mailer.js +++ b/utils/mail/mailer.js @@ -188,12 +188,25 @@ export default class NewsletterMailer { * @returns {Promise<*>} - The configured transporter. */ async #transporter(mailConfig) { - return nodemailer.createTransport({ - secure: true, - host: mailConfig.host, - port: mailConfig.port, - auth: {user: mailConfig.auth.user, pass: mailConfig.auth.pass} - }); + // Destructure from mailConfig, defaulting secure to true if not specified + const { secure = true, host, port, auth } = mailConfig; + + // Initialize transport options + const transportOptions = { + secure, + host, + port + }; + + // Conditionally add auth if both user and pass are provided + if (auth && auth.user && auth.pass) { + transportOptions.auth = { + user: auth.user, + pass: auth.pass + }; + } + + return nodemailer.createTransport(transportOptions); } /** @@ -256,4 +269,4 @@ export default class NewsletterMailer { return emailsSent; } -} \ No newline at end of file +} diff --git a/views/dashboard/settings.ejs b/views/dashboard/settings.ejs index 6bf6f4b..02f8b99 100644 --- a/views/dashboard/settings.ejs +++ b/views/dashboard/settings.ejs @@ -46,7 +46,7 @@