This repo includes:
- The client app with Gatsby using Gatsby default starter. Please note that the method we use here to send emails will apply to any static site generator builder framework(next.js, create react app etc.).
- The back-end API using PHP to handle the requests from the client and send the emails.
In order to send emails with PHP you will need a local web server on your computer with a solution like XAMPP. If you have a LAMP stack server then you can deploy directly on your server. Current examples use axios to send the request from the client but other methods can be used instead.
After you clone the repo use the console to cd to the project's root directory and run:
- npm install - to install npm packages.
- npm start - to start the development server.
Use form-A or form-B example components and follow the steps below:
- Replace the email address in config.php with your email.
- Replace the domain in the form-A component to the domain of your website or localhost if you are in dev.
- Create a static Gatsby site build using npm run build or gatsby build.
- Deploy the generated Gatsby static app found in the public folder to the server..
Use form-A or form-B example components and follow the steps below:
- Follow steps 1. and 2. from above.
- Add the form-A component in your app.
- Add the api folder in the same directory you deploy your app.
More examples with hooks and front-end and back-end validation soon to come!
Star if you found this helpful and enjoy!