If you need to track email opens or clicks, integrate with an email tracking service or use webhooks. Services like Mailgun or SendGrid provide these features.
Example with Mailgun:
const mailgun = require('mailgun-js');
const mg = mailgun({ apiKey: process.env.MAILGUN_API_KEY, domain: process.env.MAILGUN_DOMAIN });
const data = {
from: 'Your Name <[email protected]>',
to: '[email protected]',
subject: 'Hello',
text: 'Hello world!'
};
mg.messages().send(data, (error, body) => {
if (error) {
console.error('Error sending email:', error);
} else {
console.log('Email sent successfully:', body);
}
});
Leave a Reply