Skip to content

Commit e960c50

Browse files
akarivclaude
andcommitted
Switch contact form mailer from SendGrid to SMTP (SES)
Uses SMTP_HOST/SMTP_PORT/SMTP_USER/SMTP_PASSWORD via nodemailer instead of the SendGrid API. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 394281c commit e960c50

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

index.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,17 @@ const express = require('express');
44
const nunjucks = require('nunjucks');
55
const request = require("request");
66
const bodyParser = require('body-parser');
7-
const sgMail = require('@sendgrid/mail')
7+
const nodemailer = require('nodemailer');
88

9-
sgMail.setApiKey(process.env.SENDGRID_API_KEY)
9+
const mailTransport = nodemailer.createTransport({
10+
host: process.env.SMTP_HOST,
11+
port: parseInt(process.env.SMTP_PORT, 10),
12+
secure: parseInt(process.env.SMTP_PORT, 10) === 465,
13+
auth: {
14+
user: process.env.SMTP_USER,
15+
pass: process.env.SMTP_PASSWORD,
16+
},
17+
});
1018

1119
const app = express();
1220
const rootDir = './dist/';
@@ -55,8 +63,8 @@ app.use('/contact', bodyParser.json())
5563
html: '<div style="direction:rtl">' + req.body.body.split('\n').join('<br/>') + '</div>',
5664
};
5765
console.log(msg);
58-
sgMail
59-
.send(msg)
66+
mailTransport
67+
.sendMail(msg)
6068
.then(() => {
6169
res.status(200).json({sent: true});
6270
})

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"core-js": "^2.6.1",
3030
"d3": "^5.9.2",
3131
"d3-simple-slider": "^1.5.4",
32+
"nodemailer": "^6.9.13",
3233
"ngx-auto-unsubscribe": "^2.4.1",
3334
"ngx-rangeslider-component": "^1.0.6",
3435
"rxjs": "~6.3.3",

0 commit comments

Comments
 (0)