Skip to content

malikarslanasif131/email-verification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

Certainly, here's a README file template for your GitHub project that covers the basics of your Node.js, Express.js, and Nodemailer email verification project:

# Email Verification with Node.js, Express.js, and Nodemailer

This project is an example of how to implement email verification for user registration in a Node.js application using Express.js and Nodemailer. When a user registers, an email with a verification link is sent to their provided email address. Users can then verify their account by clicking the verification link.

## Features

- User registration with name and email.
- Email verification with a time-limited verification link.
- Automatic removal of unverified accounts after a certain time period.

## Technologies Used

- Node.js
- Express.js
- MongoDB (or any other database of your choice)
- Nodemailer for sending emails
- HTML and CSS for email templates

## Prerequisites

Before running this project, you need to have the following software and services installed:

- Node.js and npm (Node Package Manager)
- MongoDB (or a compatible database)
- A Gmail account for sending verification emails (or other SMTP email service)

## Setup

1. Clone this repository to your local machine:

   ```bash
   git clone https://github.com/yourusername/email-verification.git
   cd email-verification
  1. Install project dependencies:

    npm install
  2. Configure environment variables:

    • Create a .env file in the project root directory.
    • Define the following environment variables in your .env file:
      DB=your-mongodb-connection-string
      HOST=your-smtp-hostname
      USER=your-smtp-username
      PASS=your-smtp-password
      SERVICE=your-smtp-service
      BASE_URL=http://localhost:your-port/api
      PORT=your-port
      
  3. Start the server:

    npm start
  4. The API will be available at http://localhost:your-port/api.

Usage

  1. Register a new user by sending a POST request to /api/user with a JSON body containing name and email fields. The server will send a verification email to the provided email address.

  2. Check your email for the verification link and click on it to verify your account.

  3. If the verification link is not clicked within a certain time (5 minutes by default), the unverified user account is automatically removed.

Customization

You can customize the email templates by modifying the HTML content in the email sending function. Additionally, you can adjust the verification link expiration time in the code.

License

This project is licensed under the MIT License. See the LICENSE file for details.


This README provides an overview of your project, its features, technologies used, setup instructions, usage, customization options, and licensing information. You can further customize it to provide more details about your specific project if needed.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published