0

I'm trying to send pdfs to kindle email.

When I send it to my own email, the pdfs are added correctly.

But I get the following error when I send to kindle email:

Your message did not include any documents in the attachment or image files.

The code is as follows:

function sendEmail(subject, fileName, path) {
  const transporter = nodemailer.createTransport({
    service: "gmail",
    auth: {
      user: process.env.EMAIL,
      pass: process.env.PASS,
    },
  });

  var mailOptions = {
    from: process.env.EMAIL,
    to: process.env.KINDLE_EMAIL,
    attachments: [
      {
        filename: fileName,
        path,
        contentType: "application/pdf",
      },
    ],
  };

  return new Promise((resolve, reject) => {
    transporter.sendMail(mailOptions, function (error, info) {
      if (error) {
        console.log("error send email " + error);
        reject(error);
      } else {
        console.log("Email sent: " + info.response);
        resolve();
      }
    });
  });
}

1 Answers1

0

I managed to solve the problem.

In my case, the problem happened because I was not putting the .pdf extension in the file name