Я использую sendgrid API для отправки транзакционных электронных писем через нодмейлер. Но каждый раз, когда я отправляю, это нечитаемо. Вот мой post
запрос ниже.
router.post('/sendPendingEmail', async (req, res) => {
var toEmail = req.body.email
var pdfURL = req.body.pdfDataUri
sgMail.setApiKey(process.env.SENDGRID_API_KEY)
let mailOptions = {
from: 'DocuSiner <patents@docusigner.com>',
to: toEmail,
subject: 'Patent Certificate - DocuSigner',
html: `<p>Dear, Sir/Madam,</p><br><p>This is to inform you that the patent e-form submitted on the DocuSigner portal is <strong>APPROVED</strong>. Below is the Patent Certificate, please download the same for future use: </p><p>Thank You.</p>`,
attachments: [
{
filename: 'patent.pdf',
content: new Buffer.from(pdfURL).toString('base64'),
type: 'application/pdf',
disposition: 'attachment'
}
]
}
await sgMail.send(mailOptions, (err, sent) => {
if (err) {
res.send(err)
}
res.send({
info: sent,
msg: 'Email Sent'
})
})
})