-
-
Notifications
You must be signed in to change notification settings - Fork 779
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: SMTP integration and email notifications (#631)
- Loading branch information
Showing
14 changed files
with
188 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,14 @@ services: | |
# - DEFAULT_ADMIN_NAME=Demo Demo | ||
# - DEFAULT_ADMIN_USERNAME=demo | ||
|
||
# Email Notifications (https://nodemailer.com/smtp/) | ||
# - SMTP_HOST= | ||
# - SMTP_PORT=587 | ||
# - SMTP_SECURE=true | ||
# - SMTP_USER= | ||
# - SMTP_PASSWORD= | ||
# - SMTP_FROM="Demo Demo" <[email protected]> | ||
|
||
# - OIDC_ISSUER= | ||
# - OIDC_CLIENT_ID= | ||
# - OIDC_CLIENT_SECRET= | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,14 @@ services: | |
# - DEFAULT_ADMIN_NAME=Demo Demo | ||
# - DEFAULT_ADMIN_USERNAME=demo | ||
|
||
# Email Notifications (https://nodemailer.com/smtp/) | ||
# - SMTP_HOST= | ||
# - SMTP_PORT=587 | ||
# - SMTP_SECURE=true | ||
# - SMTP_USER= | ||
# - SMTP_PASSWORD= | ||
# - SMTP_FROM="Demo Demo" <[email protected]> | ||
|
||
# - OIDC_ISSUER= | ||
# - OIDC_CLIENT_ID= | ||
# - OIDC_CLIENT_SECRET= | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,14 @@ SECRET_KEY=notsecretkey | |
# DEFAULT_ADMIN_NAME=Demo Demo | ||
# DEFAULT_ADMIN_USERNAME=demo | ||
|
||
# Email Notifications (https://nodemailer.com/smtp/) | ||
# SMTP_HOST= | ||
# SMTP_PORT=587 | ||
# SMTP_SECURE=true | ||
# SMTP_USER= | ||
# SMTP_PASSWORD= | ||
# SMTP_FROM="Demo Demo" <[email protected]> | ||
|
||
# OIDC_ISSUER= | ||
# OIDC_CLIENT_ID= | ||
# OIDC_CLIENT_SECRET= | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -232,6 +232,7 @@ module.exports = { | |
toList: _.pick(values.list, ['id', 'name']), | ||
}, | ||
}, | ||
board: inputs.board, | ||
}); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
module.exports = { | ||
inputs: { | ||
to: { | ||
type: 'string', | ||
required: true, | ||
}, | ||
subject: { | ||
type: 'string', | ||
required: true, | ||
}, | ||
html: { | ||
type: 'string', | ||
required: true, | ||
}, | ||
}, | ||
|
||
async fn(inputs) { | ||
const transporter = sails.hooks.smtp.getTransporter(); // TODO: check if active? | ||
|
||
try { | ||
const info = await transporter.sendMail({ | ||
...inputs, | ||
from: sails.config.custom.smtpFrom, | ||
}); | ||
|
||
sails.log.info('Email sent: %s', info.messageId); | ||
} catch (error) { | ||
sails.log.error(error); | ||
} | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const nodemailer = require('nodemailer'); | ||
|
||
module.exports = function smtpServiceHook(sails) { | ||
let transporter = null; | ||
|
||
return { | ||
/** | ||
* Runs when this Sails app loads/lifts. | ||
*/ | ||
|
||
async initialize() { | ||
if (sails.config.custom.smtpHost) { | ||
transporter = nodemailer.createTransport({ | ||
pool: true, | ||
host: sails.config.custom.smtpHost, | ||
port: sails.config.custom.smtpPort, | ||
secure: sails.config.custom.smtpSecure, | ||
auth: sails.config.custom.smtpUser && { | ||
user: sails.config.custom.smtpUser, | ||
pass: sails.config.custom.smtpPassword, | ||
}, | ||
}); | ||
sails.log.info('SMTP hook has been loaded successfully'); | ||
} | ||
}, | ||
|
||
getTransporter() { | ||
return transporter; | ||
}, | ||
|
||
isActive() { | ||
return transporter !== null; | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters