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: "[email protected]",
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/[email protected]
- Verify code:
curl -X POST http://localhost:3000/verify/check/[email protected]/123456
Success:
{
"message": "Code verified successfully"
}
Error:
{
"error": "invalid code"
}
- Configure SMTP settings in
config/config.go
- Run the application:
go run main.go
- Fiber v2
- Go 1.21+