I am looking to send a file as attachment and some body text using smtp-client. Can someone share the what parameters to be sent to smtp.data() method. I am not sure about what will be values of header & body.
try {
await smtp.connect();
await smtp.greet({hostname: SMTP_SELFHOSTNAME});
await smtp.secure();
await smtp.greet({hostname: SMTP_SELFHOSTNAME});
await smtp.authPlain({username: SMTP_USERNAME, password: SMTP_PASSWORD});
await smtp.mail({from: SMTP_FROMADDRESS});
await smtp.rcpt({to: destinationEmail});
await smtp.data(header + body);
await smtp.quit();
} catch (err) {
console.log('Error sending email:', err);
}
I am looking to send a file as attachment and some body text using smtp-client. Can someone share the what parameters to be sent to smtp.data() method. I am not sure about what will be values of header & body. try { await smtp.connect(); await smtp.greet({hostname: SMTP_SELFHOSTNAME}); await smtp.secure(); await smtp.greet({hostname: SMTP_SELFHOSTNAME}); await smtp.authPlain({username: SMTP_USERNAME, password: SMTP_PASSWORD}); await smtp.mail({from: SMTP_FROMADDRESS}); await smtp.rcpt({to: destinationEmail}); await smtp.data(header + body); await smtp.quit(); } catch (err) { console.log('Error sending email:', err); }
Any help will be much appreciated.