I'm trying to use Nodemailer for this, but I can't use an attachment in the input, or I don't know how https://nodemailer.com/message/attachments/
please help, anything is helpful for me
postuler.js
let details = {
name: name.value,
prenom: prenom.value,
email: email.value,
telephone: telephone.value,
cv: cv.file,
profil: profil.value,
motivation: motivation.value
};
let response = await fetch("http://localhost:5000/postuler", {
method: "POST",
headers: {
"Content-Type": "application/json;charset=utf-8",
},
body: JSON.stringify(details),
});
server.js
router.post("/postuler", (req, res) => {
const name = req.body.name;
const prenom = req.body.prenom
const email = req.body.email;
const telephone = req.body.telephone;
const cv = req.files;
const profil = req.body.profil;
const motivation = req.body.motivation;
const mail = {
from: email,
to: "*************@gmail.com",
subject: `Contact Form ${name} ${prenom}`,
html: `<p>Name et Prenom: ${name} ${prenom}</p>
<p>Email: ${email}</p>
<p>Telephone: ${telephone}</p>
<p>Linkedin: ${profil}</p>
<p>Motivation: ${motivation}</p>
`,
attachments: [
{ // use URL as an attachment
filename: cv.originalname,
contentType: 'application/pdf',
path: cv.path
},
]
};