I’m making an email bot and I have nodemailer installed into my node.js app. I was wondering if there was a way to send a json of the form the user has to fill in for the bot to email to the node.js app to process it and send the email.
then in a separate line of code that is not the nodemailer, set variables of the data. Then do something like this
var message = {
from: “the@email.com",
to: sendto,
subject: thesubject,
text: yougetthepoint,
};
sendto, thesubject, and yougetthepoint were variables set earlier from the json file. and that’s what I’m trying to do
Also is there a way with nodemailer to detect when you send an email to the email address? You don’t have to solve this issue because I might not need it but if you can thank you in advance
For express, you’re looking for the express.json middleware (also part of body-parser) it’ll automatically decode any json it sees and put it into req.body. However you mentioned a form and forms usually submit using a url encoding of the data in the form. So express.urlencoded might be more useful