This is a simple example of a contact form built using Next.js and Tailwind CSS, with the ability to send emails using the Nodemailer library. This project aims to provide a starting point for integrating a contact form into your Next.js application.
Before getting started, ensure that you have the following installed on your machine:
To set up the project locally, follow these steps:
https://github.com/maryamtufail/nodemailer_form_nextjs.git
to your local machine or download the source code as a ZIP file.nodemailer_form_nextjs
.npm install
to install the project dependencies..env.local
file in the project root and provide the necessary environment variables (see the Environment Variables section below for details).npm run dev
to start the development server.http://localhost:3000
to see the form in action.The following environment variables are required to configure the email service:
GMAIL_USER
= YOUR_EMAILGMAIL_PASSWORD
= YOUR_PASSCODEThis is not your email passwords.
https://shorturl.at/rKTZ9
or Access your google account > Security > 2-Step Verification > App Passwords (Scroll down at bottom see this)
select app > Other > Write nodemailer
Make sure to provide appropriate values for these variables in your .env.local
file.
Feel free to modify the project structure as per your requirements.
This project was inspired by the following resources:
With this simple setup, you can easily add a contact form to your Next.js application using Tailwind CSS for styling and Nodemailer for sending emails. Customize the form, add validation, and enhance the functionality to meet your specific requirements.
Happy coding!