const fs = require('fs');
const pug = require('pug');
-const sendgrid = require('@sendgrid/mail');
+const { Resend } = require('resend');
const texttemplate = fs.readFileSync(__dirname + '/template.txt', 'utf-8');
return texttemplate.replace(/<token>/, token);
};
-sendgrid.setApiKey(process.env.SENDGRID_API_KEY);
+const resend = new Resend(process.env.RESEND_API_KEY);
/**
* Send the reset password email.
*/
exports.sendEmail = function(to, token, callback) {
- sendgrid.send(
- {
+ resend.emails
+ .send({
from: 'binb <no-reply@binb.co>',
to: to,
subject: 'binb password recovery',
html: HTMLMessage({ token: token }),
text: plaintextMessage(token)
- },
- callback
- );
+ })
+ .then(function({ error }) {
+ callback(error);
+ })
+ .catch(callback);
};
"node": ">=16.0.0"
},
"dependencies": {
- "@sendgrid/mail": "^7.3.0",
"async": "^3.1.1",
"body-parser": "^1.18.3",
"canvas": "^2.4.1",
"express": "^4.16.4",
"express-session": "^1.16.1",
"forwarded-for": "^1.0.1",
+ "ioredis": "^5.3.2",
"primus": "^8.0.1",
"primus-emitter": "^3.1.1",
"primus-rooms": "^3.4.1",
"pug": "^3.0.2",
- "ioredis": "^5.3.2",
+ "resend": "^6.0.2",
"serve-favicon": "^2.5.0",
"uglify-js": "^3.5.4",
"ws": "^8.13.0"