The Email Validator Service is a comprehensive and production-ready service built in Go, designed to validate email addresses through various checks. It supports multiple validation mechanisms including syntax validation, role-based email checks, MX records verification, SMTP validation, and more.
This Validator Service utilizes the EmailValidator library as a third-party module for email validation. The EmailValidator library can be found here.
This service offers robust email validation functionality to enhance the reliability of your application's data processing.
- Syntax Validation: Ensures the email address follows standard email syntax rules.
- Role-Based Email Check: Identifies and rejects role-based email addresses (e.g., admin@example.com).
- MX Record Verification: Checks if the email's domain has valid MX records.
- SMTP Validation: Verifies the existence of the email address via SMTP.
- Ban Words in Username Check: Blocks email addresses with specific banned words in the username.
- Blacklisted Emails Check: Rejects email addresses that are blacklisted.
- DNS Check: Validates the domain's DNS records.
- RFC Compliance Check: Ensures the email address complies with RFC standards.
- No RFC Warnings Check: Ensures there are no RFC warnings.
- Gravatar Check: Checks if the email address is associated with a Gravatar.
- Go 1.16+
- Docker (optional, for containerized deployment)
git clone https://github.com/sufimalek/email-validator-service.git
cd email-validator-service
make deps
Create a .env
file in the root directory with the following content:
PORT=8080
make build
make run
Build the Docker image:
docker build -t email-validator-service .
Run the Docker container:
docker run -p 8080:8080 --env-file .env email-validator-service
- URL:
/api/validate
- Method:
POST
- Request Body:
{ "email": "example@example.com" }
- Response (Valid Email):
{ "is_valid": true, }
- Response (Invalid Email):
{ "is_valid": false, "message": "Email validation failed" }
You can use curl
to make a request to the API:
curl -X POST http://localhost:8080/api/validate -H "Content-Type: application/json" -d '{"email": "test@example.com"}'
{
"is_valid": true,
}
email-validator-service/
|-- cmd/
| |-- server/
| |-- main.go
|-- internal/
| |-- server/
| |-- handlers.go
| |-- middleware.go
| |-- routes.go
|-- config/
| |-- config.go
|-- vendor/
|-- go.mod
|-- go.sum
|-- README.md
|-- Makefile
To run tests, use the following command:
make test
We welcome contributions! Please fork the repository and submit a pull request.
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Commit your changes and push to your fork.
- Submit a pull request describing your changes.
This project is licensed under the MIT License.
For any inquiries or support, please open an issue on the GitHub repository or contact us at suf_sap@hotmail.com.