How to send data from a website to node.js?

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

disableFileAccess if true, then does not allow to use files as content. Use it when you want to use JSON data from untrusted source as the email.

from Message configuration :: Nodemailer

this could maybe solve your second question.

1 Like

thanks, this does solve my second question. However I edited my first question so it makes more sense of what I’m trying to do

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

1 Like

Sorry for the long reply! I got it installed on my node.js app and I’m wondering how to send the data this onto my website.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.