An open API service indexing awesome lists of open source software.

https://github.com/zeeshandev15/send-form-data-to-gmail-via-emailjs

To send form data to Gmail via EmailJS in React, use react-hook-form for form handling and validation. On form submission, trigger emailjs.sendForm() with your form reference to send the data to an EmailJS service template, which forwards it to Gmail. Reset the form after submission.
https://github.com/zeeshandev15/send-form-data-to-gmail-via-emailjs

nextjs reacthookform typescript zod-validation

Last synced: 4 months ago
JSON representation

To send form data to Gmail via EmailJS in React, use react-hook-form for form handling and validation. On form submission, trigger emailjs.sendForm() with your form reference to send the data to an EmailJS service template, which forwards it to Gmail. Reset the form after submission.

Awesome Lists containing this project

README

          





Project Banner



Next.js
EmailJS
reacthookform
tailwindcss
Zod

Send-form-data-to-Gmail-via-EmailJS


## πŸ“‹ Table of Contents

1. πŸ€– [Introduction](#introduction)
2. βš™οΈ [Tech Stack](#tech-stack)
3. πŸ”‹ [Features](#features)
4. 🀸 [Quick Start](#quick-start)
5. πŸ•ΈοΈ [Snippets (Code to Copy)](#snippets)
6. πŸš€ [More](#more)

## πŸ€– Introduction

To send form data to Gmail via EmailJS in React, use react-hook-form for form handling and validation. On form submission, trigger emailjs.sendForm() with your form reference to send the data to an EmailJS service template, which forwards it to Gmail. Reset the form after submission!

If you're getting started and need assistance or face any bugs, join our active Discord community with over **34k+** members. It's a place where people help each other out.

## βš™οΈ Tech Stack

- Next.js
- TailwindCSS
- Zod
- ReactHookForm

## πŸ”‹ Features

πŸ‘‰ **Form Handling**: Uses react-hook-form for managing form state and validation.

πŸ‘‰ **Data Validation**: Validates user inputs with Zod schema..

πŸ‘‰ **Email Sending**: Integrates EmailJS to send form data directly to Gmail.

πŸ‘‰ **Real-time Feedback**: Displays success or error messages using toast notifications.

πŸ‘‰ **Form Reset**: Automatically clears form fields after successful submission.

πŸ‘‰ **Responsive Design**: Utilizes Tailwind CSS for a responsive and clean UI.

## 🀸 Quick Start

Follow these steps to set up the project locally on your machine.

**Prerequisites**

Make sure you have the following installed on your machine:

- [Git](https://git-scm.com/)
- [Node.js](https://nodejs.org/en)
- [yarn](https://yarnpkg.com/) (Package Manager)

**Cloning the Repository**

```bash
git clone https://github.com/Hi-Dear-486/Send-form-data-to-Gmail-via-EmailJS.git
cd ./
```

**Installation**

Install the project dependencies using yarn:

```bash
yarn install
```

**Set Up Environment Variables**

Create a new file named `.env.local` in the root of your project and add the following content:

Replace the placeholder values with your actual Firebase credentials. You can obtain these credentials by signing up on the [Firebase website (https://firebase.google.com/).

**Running the Project**

```bash
yarn run dev
```

Open [http://localhost:3000](http://localhost:3000) in your browser to view the project.

## πŸ•ΈοΈ Snippets

tailwind.config.js

```typescript
import type { Config } from "tailwindcss";

export default {
darkMode: ["class"],
content: [
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
"./components/**/*.{js,ts,jsx,tsx,mdx}",
"./app/**/*.{js,ts,jsx,tsx,mdx}",
],
theme: {
extend: {
colors: {
background: "hsl(var(--background))",
foreground: "hsl(var(--foreground))",
card: {
DEFAULT: "hsl(var(--card))",
foreground: "hsl(var(--card-foreground))",
},
popover: {
DEFAULT: "hsl(var(--popover))",
foreground: "hsl(var(--popover-foreground))",
},
primary: {
DEFAULT: "hsl(var(--primary))",
foreground: "hsl(var(--primary-foreground))",
},
secondary: {
DEFAULT: "hsl(var(--secondary))",
foreground: "hsl(var(--secondary-foreground))",
},
muted: {
DEFAULT: "hsl(var(--muted))",
foreground: "hsl(var(--muted-foreground))",
},
accent: {
DEFAULT: "hsl(var(--accent))",
foreground: "hsl(var(--accent-foreground))",
},
destructive: {
DEFAULT: "hsl(var(--destructive))",
foreground: "hsl(var(--destructive-foreground))",
},
border: "hsl(var(--border))",
input: "hsl(var(--input))",
ring: "hsl(var(--ring))",
chart: {
"1": "hsl(var(--chart-1))",
"2": "hsl(var(--chart-2))",
"3": "hsl(var(--chart-3))",
"4": "hsl(var(--chart-4))",
"5": "hsl(var(--chart-5))",
},
},
borderRadius: {
lg: "var(--radius)",
md: "calc(var(--radius) - 2px)",
sm: "calc(var(--radius) - 4px)",
},
},
},
plugins: [require("tailwindcss-animate")],
} satisfies Config;
```

## πŸš€ More
**Advance your skills with Next Js**

Enjoyed creating this project? Dive deeper for a richer learning adventure. They're packed with detailed explanations, cool features, and exercises to boost your skills. Give it a go!


Project Banner




#