0

Im sending a password reset email and as its content im rendering html. In my backend (node) I use path to get the relative path so I can add an image but its not being displayed. Only when I host the image somewhere, I can add it to my html. otherwise if its in my project only and im using relative ath, no image is displayed in the email. What am I doing wrong? Thanks!!

folder structure: resources/logo.png resources/email.js

resources/email.js

const path = require('path');
const logoPath = path.join(__dirname, '..', 'logo.png');

const resetPwdEmail= (link, resetPasswordToken) => {
    return (
        `
        <!DOCTYPE html>

<html>
<head>
    <style>...</style>
</head>
<body>
<div>
<img src=${}/>
      <a class="link" href=${link}/${resetPasswordToken}>reset password</a>
    <p>...</p>
</div>
</body>
</html>
        `
    )
};

module.exports = {resetPwdEmail};

services/index.js

...
 const apiInstance = new SibApiV3Sdk.TransactionalEmailsApi();
        const sendSmtpEmail = {
            sender: {
                email: 'from@email.de'
            },
            to: [{
                email: 'to@yahoo.com'
            }],
            subject: 'hello',
            htmlContent: resetPwdEmail(link, resetPasswordToken, logoPath),
        };
...
learncode
  • 127
  • 6
  • 1
    Hi @learncode, It is mandatory to host the attachment file as is clearly mentioned in the official documentation. `Pass the absolute URL (no local file) or the base64 content of the attachment along with the attachment name.` Documentation reference: https://developers.brevo.com/reference/sendtransacemail Hope this helps! – rudy0807 May 25 '23 at 16:56

0 Answers0