Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The process of acquiring the path for sending an email with an attached file or embedded image using Nodemailer is as follows:

  1. Install Nodemailer using npm install nodemailer command.

  2. Import nodemailer module in your file.

  3. Create a transport object with the SMTP server details, i.e., host, port, authentication details, etc.

  4. Create a message object, which contains the necessary details of the email such as subject, body, from, to, cc, bcc, etc.

  5. For attaching file, create attachment object with necessary details such as path, filename, content type, etc.

  6. For embedding image within the body of the email, get the file as a buffer and convert it to a base64 encoded string using the fs module.

  7. Add the attachment or image to the message object.

  8. Finally, send the email using the sendMail method with the transport and message objects as arguments.