Reputation: 1
I am still a newbie to React. I made a react app and integrated it into an existing website. The app is a multi-step dynamic form, which generates input fields and options based on the users answers.
When the user clicks next step on this multi-step form a new step slide is generated with inputs based on previous information. By doing this old form fields are no longer rendered.
All the field information are stored in the state as an object. Like:
formValues: {
checkboxes_what_colors: {
blue: true,
green: true,
orange: false
},
email: "[email protected]",
firstName: "Kookie",
lastName: "Doh",
option_todo_what: "track"
}
So if I access this.state.formValues
I would be able to retrieve an object with the field names and the values that was entered or selected.
The thing is I need to send this.state.formValues
in a email when the user clicks submit and I am not sure how to do that.
What would be the standard way to send React state information via e-mail?
Upvotes: 0
Views: 555
Reputation: 2652
You would need some software on the server to send an email, it's not possible to send an email from the browser directly. You would normally make an AJAX call where you send data -- your state, or parts of it -- to a server you control and the script on the server takes responsibility for templating out the email and sending it. It's a common enough use case that there isn't really one way of doing it, there are probably a zillion little packages out there for sending email and many server-side application frameworks would have a built-in utility for it.
Upvotes: 1