I am working on a website that I used create-react-app to create. I need to make a contact page where the information entered will be sent to a specified email.
After doing some research I discovered this is going to require me to setup some back-end. I am very unfamiliar with back-end programming. I know about nodejs and am somewhat capable of setting up a basic server using that, but I have no clue how to connect it to the react site, or if I even need a node server (just mentioned it because I found Nodemailer).
What's a good back-end setup I should use? All I need to use it for is sending an input field's value to a specific email.
I'm sorry this is such a noob/vague question, I am just looking for some direction on what to start researching and learning. I don't expect a detailed answer on the purpose and precise operations of a back-end server, just some helpful guidance or somewhere to start learning!
Any help is really appreciated!
I am working on a website that I used create-react-app to create. I need to make a contact page where the information entered will be sent to a specified email.
After doing some research I discovered this is going to require me to setup some back-end. I am very unfamiliar with back-end programming. I know about nodejs and am somewhat capable of setting up a basic server using that, but I have no clue how to connect it to the react site, or if I even need a node server (just mentioned it because I found Nodemailer).
What's a good back-end setup I should use? All I need to use it for is sending an input field's value to a specific email.
I'm sorry this is such a noob/vague question, I am just looking for some direction on what to start researching and learning. I don't expect a detailed answer on the purpose and precise operations of a back-end server, just some helpful guidance or somewhere to start learning!
Any help is really appreciated!
Share Improve this question asked Aug 17, 2017 at 0:14 Gage Hendy Ya BoyGage Hendy Ya Boy 1,5744 gold badges20 silver badges37 bronze badges 1- You may want to take a look at EmailJS, which allows sending email using pre-built templates directly from Javascript [disclosure - I'm one of the creators] – Sasha Commented Aug 20, 2017 at 16:43
1 Answer
Reset to default 7I can think of two options to connect to the back-end to send an email.
API: You create an endpoint on your backend (i.e. https://yourdomain./api/sendemail). Using expressjs, or some other server side library, you create that endpoint to receive a
POST
request. (https://expressjs./en/starter/basic-routing.html) You then use the front-end (fetch: https://developer.mozilla/en-US/docs/Web/API/Fetch_API/Using_Fetch) to call the endpoint with the data needed in the email and in turn the endpoint calls your send email function with Nodemailer or whatever.Form Submit: The other option is similar to the first in that it sends a
POST
request with the form data to the back-end. This requires that the server send back a new page and your browser will then reload. Where as the first option can be done without a page reload.
Not an expert on this but those are the two options I know of. Good luck!