]> git.example.dev Git - binbsis50.git/commitdiff
replaced Sendgrid with Resend
authorLuigi Pinca <luigipinca@gmail.com>
Sat, 6 Sep 2025 12:54:50 +0000 (14:54 +0200)
committerLuigi Pinca <luigipinca@gmail.com>
Sat, 6 Sep 2025 12:54:50 +0000 (14:54 +0200)
lib/email/mailer.js
package.json

index 8e5d96def3a452ba8a644500a523bc4a728e678d..d63203913f66b0a6a0f5bd308f937310fe0a3c40 100644 (file)
@@ -2,7 +2,7 @@
 
 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');
 
@@ -20,21 +20,23 @@ const plaintextMessage = function(token) {
   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);
 };
index 8b8139b51015728663988cc2be06f9b2ac16897e..632fc807c33873b9b190dc306908aaabb746ae85 100644 (file)
@@ -16,7 +16,6 @@
     "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"