Skip to content

Help needed to send attachments #12

@kapilsanchihar

Description

@kapilsanchihar

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions