mirror of
https://github.com/PretendoNetwork/website.git
synced 2026-03-21 17:24:28 -05:00
chore: move email sending to AWS SES
This commit is contained in:
parent
987a73e646
commit
3f9d2e6964
|
|
@ -33,9 +33,12 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"gmail": {
|
"email": {
|
||||||
"user": "username",
|
"ses": {
|
||||||
"pass": "password",
|
"region": "AWS SES us-east-1",
|
||||||
|
"key": "AWS SES access key",
|
||||||
|
"secret": "AWS SES secret key"
|
||||||
|
},
|
||||||
"from": "Firstname Lastname <user@domain.com>"
|
"from": "Firstname Lastname <user@domain.com>"
|
||||||
},
|
},
|
||||||
"trello": {
|
"trello": {
|
||||||
|
|
|
||||||
1926
package-lock.json
generated
1926
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
|
|
@ -22,6 +22,7 @@
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/PretendoNetwork/website#readme",
|
"homepage": "https://github.com/PretendoNetwork/website#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@aws-sdk/client-ses": "^3.515.0",
|
||||||
"@discordjs/rest": "^0.5.0",
|
"@discordjs/rest": "^0.5.0",
|
||||||
"browserify": "^17.0.0",
|
"browserify": "^17.0.0",
|
||||||
"colors": "^1.4.0",
|
"colors": "^1.4.0",
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,38 @@
|
||||||
const nodemailer = require('nodemailer');
|
const nodemailer = require('nodemailer');
|
||||||
|
const aws = require('@aws-sdk/client-ses');
|
||||||
const config = require('../config.json');
|
const config = require('../config.json');
|
||||||
|
|
||||||
const transporter = nodemailer.createTransport({
|
let disableEmail = false;
|
||||||
host: 'smtp.gmail.com',
|
let transporter;
|
||||||
port: 587,
|
|
||||||
secure: false,
|
if (!config.email?.from?.trim() || !config.email?.ses?.region?.trim() || !config.email?.ses?.key?.trim() || !config.email?.ses?.secret?.trim()) {
|
||||||
auth: {
|
disableEmail = true;
|
||||||
user: config.gmail.user,
|
}
|
||||||
pass: config.gmail.pass
|
|
||||||
}
|
if (!disableEmail) {
|
||||||
});
|
const ses = new aws.SES({
|
||||||
|
apiVersion: '2010-12-01',
|
||||||
|
region: config.email.ses.region,
|
||||||
|
credentials: {
|
||||||
|
accessKeyId: config.email.ses.key,
|
||||||
|
secretAccessKey: config.email.ses.secret
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
transporter = transporter = nodemailer.createTransport({
|
||||||
|
SES: {
|
||||||
|
ses,
|
||||||
|
aws
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async function sendMail(options) {
|
async function sendMail(options) {
|
||||||
options.from = config.gmail.from;
|
if (transporter) {
|
||||||
|
options.from = config.email.from;
|
||||||
|
|
||||||
return await transporter.sendMail(options);
|
await transporter.sendMail(options);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user