Next.js Discord

Discord Forum

Nodemailer Attachements not working

Unanswered
Asian black bear posted this in #help-forum
Open in Discord
Asian black bearOP
Hello I am trying to send an automatic email from my react website. I am using the nodemailer in order to do this. Unfortunately when I do send the email with a pdf attachement in my inbox I don't receive the pdf attachement but only the email with the subject and the html text with it.
Here is a snip bit of the code.
let mailOptions = {
    from: '...', // Replace this with your Email Id.
    to: '...', // Replace this with Recipient Email Id.
    subject: 'Testing Nodemailer',
    html: `><h1>Acta wants to thank your for using our services.</h1>
    <p>
    If you have any further questions or requests please feel free to email us ...
    <p/>`,
    attachements: [
        {
        filename: 'Report',
        path: 'pdf_2.pdf',
        }
    ]
        
};

transporter.sendMail(mailOptions, (error, info) => {
    if(error){
        console.log('Error Occured' + error)
    }
    else {
        console.log('Successfully Email Sent To:' + mailOptions.to, info.response)
    }
})

2 Replies

Asian black bearOP
Hello I am trying to send an automatic email from my react website. I am using the nodemailer in order to do this. Unfortunately when I do send the email with a pdf attachement in my inbox I don't receive the pdf attachement but only the email with the subject and the html text with it.
Here is a snip bit of the code.
let mailOptions = {
    from: '...', // Replace this with your Email Id.
    to: '...', // Replace this with Recipient Email Id.
    subject: 'Testing Nodemailer',
    html: `><h1>Acta wants to thank your for using our services.</h1>
    <p>
    If you have any further questions or requests please feel free to email us ...
    <p/>`,
    attachements: [
        {
        filename: 'Report',
        path: 'pdf_2.pdf',
        }
    ]
        
};

transporter.sendMail(mailOptions, (error, info) => {
    if(error){
        console.log('Error Occured' + error)
    }
    else {
        console.log('Successfully Email Sent To:' + mailOptions.to, info.response)
    }
})
I have also looked on the internet and tried changing path to filepath without success