// Import necessary modules
const nodemailer = require('nodemailer');
const anonymousTransport = require('nodemailer-anonymous-transport');
// Create a transporter with anonymous configuration
const transporter = nodemailer.createTransport(anonymousTransport());
// Email content
const mailOptions = {
from: 'sender@example.com',
to: 'recipient@example.com',
subject: 'Anonymous Email',
html: 'This is an anonymous email sent with HTML content
',
attachments: [
{
filename: 'example.txt',
content: 'This is a text file attachment',
},
],
};
// Send email
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
console.log('Error occurred: ', error);
} else {
console.log('Email sent: ' + info.response);
}
});