| title | keywords | description | |||||
|---|---|---|---|---|---|---|---|
Email Verification Service |
|
Email verification service with code generation and validation |
A clean architecture based email verification service that generates and validates verification codes.
- Clean Architecture implementation
- In-memory verification code storage
- SMTP email service integration
- Code generation and hashing
- Configurable code expiration
- Thread-safe operations
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
Update config/config.go with your SMTP settings:
func GetConfig() *Config {
return &Config{
SMTPHost: "smtp.gmail.com",
SMTPPort: 587,
SMTPUser: "your-email@gmail.com",
SMTPPassword: "your-app-password",
CodeExpiration: time.Minute * 1,
}
}| Method | URL | Description |
|---|---|---|
| POST | /verify/send/:email | Send verification code |
| POST | /verify/check/:email/:code | Verify the received code |
- Send verification code:
curl -X POST http://localhost:3000/verify/send/user@example.com- Verify code:
curl -X POST http://localhost:3000/verify/check/user@example.com/123456Success:
{
"message": "Code verified successfully"
}Error:
{
"error": "invalid code"
}- Configure SMTP settings in
config/config.go - Run the application:
go run main.go- Fiber v3
- Go 1.25+