Skip to content

Commit

Permalink
Support username and password in SMTP
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Sørlie <[email protected]>
  • Loading branch information
SuperManifolds committed Feb 20, 2025
1 parent cc5388e commit 7d6026d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/classes/Mail.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,17 @@ export default class Mail {
* Create a mail sender class instance
*/
constructor () {
let auth = undefined
if (config.smtp.username && config.smtp.password) {
auth = {
user: config.smtp.username,
pass: config.smtp.password,
}
}
this.transporter = nodemailer.createTransport({
host: config.smtp.hostname,
port: config.smtp.port,
auth,
})
}

Expand Down
4 changes: 3 additions & 1 deletion src/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ const config = {
username: recommended('FRAPI_SLACK_USERNAME', [], undefined),
},
smtp: {
hostname: recommended('FRAPI_SMTP_HOSTNAME', [], 'smtp-relay.gmail.com'),
hostname: optional('FRAPI_SMTP_HOSTNAME', [], 'smtp-relay.gmail.com'),
username: optional('FRAPI_SMTP_USERNAME', [], undefined),
password: optional('FRAPI_SMTP_PASSWORD', [], undefined),
port: recommended('FRAPI_SMTP_PORT', [toNumber], 587),
sender: recommended('FRAPI_SMTP_SENDER', [], '[email protected]'),
},
Expand Down

0 comments on commit 7d6026d

Please sign in to comment.