Skip to content

Latest commit

 

History

History
99 lines (77 loc) · 2.54 KB

README.md

File metadata and controls

99 lines (77 loc) · 2.54 KB
title keywords description
Email Verification Service
email
verification
smtp
golang
fiber
Email verification service with code generation and validation

Email Verification Service with Fiber

Github StackBlitz

A clean architecture based email verification service that generates and validates verification codes.

Features

  • Clean Architecture implementation
  • In-memory verification code storage
  • SMTP email service integration
  • Code generation and hashing
  • Configurable code expiration
  • Thread-safe operations

Project Structure

email-verification/
├── api/
│   └── handlers/         # HTTP handlers
├── application/          # Application business logic
├── domain/              # Domain models and interfaces
├── infrastructure/      # External implementations
│   ├── code/           # Code generation
│   ├── email/          # SMTP service
│   └── repository/     # Data storage
└── config/             # Configuration

Configuration

Update config/config.go with your SMTP settings:

func GetConfig() *Config {
    return &Config{
        SMTPHost:       "smtp.gmail.com",
        SMTPPort:       587,
        SMTPUser:       "[email protected]",
        SMTPPassword:   "your-app-password",
        CodeExpiration: time.Minute * 1,
    }
}

API Endpoints

Method URL Description
POST /verify/send/:email Send verification code
POST /verify/check/:email/:code Verify the received code

Example Usage

  1. Send verification code:
curl -X POST http://localhost:3000/verify/send/[email protected]
  1. Verify code:
curl -X POST http://localhost:3000/verify/check/[email protected]/123456

Response Examples

Success:

{
    "message": "Code verified successfully"
}

Error:

{
    "error": "invalid code"
}

How to Run

  1. Configure SMTP settings in config/config.go
  2. Run the application:
go run main.go

Dependencies