-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnode.js
More file actions
22 lines (19 loc) · 666 Bytes
/
node.js
File metadata and controls
22 lines (19 loc) · 666 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
require('dotenv').config();
console.log("Using key:", process.env.myapikey); // Should show your SG key
const sgMail = require('@sendgrid/mail');
sgMail.setApiKey(process.env.myapikey);
const msg = {
to: '[email protected]',
from: '[email protected]', // Must be verified in SendGrid Dashboard
subject: 'Test Notification',
text: 'This is your email notification body.',
html: '<strong>This is your email notification body.</strong>',
};
sgMail
.send(msg)
.then(() => {
console.log('Email sent successfully!');
})
.catch((error) => {
console.error('Error details:', error.response.body); // This shows the specific SendGrid error
});