xpepermint / smtp-client

Simple, promisified, protocol-based SMTP client for Node.js.
36 stars 13 forks source link

Help needed to send attachments #12

Open kapilsanchihar opened 3 years ago

kapilsanchihar commented 3 years ago

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.