Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
dns-smtp-email-validator
Advanced tools
DNS and SMTP Email Validator is a robust Python library designed to validate email addresses at multiple levels. It checks the format, domain, and MX records, and even communicates with the mail server to confirm the existence of the recipient's email address.
Install the package via pip:
pip install dns-smtp-email-validator
from dns_smtp_email_validator import DNSSMTPEmailValidator
# Instantiate the validator
validator = DNSSMTPEmailValidator(email="test@example.com")
# Validate the email
if validator.is_valid():
print("✅ Email is valid!")
else:
print("❌ Invalid email!")
print("Errors:", validator.errors)
validator = DNSSMTPEmailValidator(
email="test@example.com",
sender_email="mycustomsender@domain.com",
raise_exception=True
)
if validator.is_valid():
print("✅ Email is valid!")
else:
print("❌ Email validation failed!")
You can configure allowed email domains through environment variables. Use a .env
file or system-level configuration.
.env
FileALLOWED_EMAIL_DOMAINS=gmail.com,yahoo.com,outlook.com
If ALLOWED_EMAIL_DOMAINS
is not provided, the library uses the following defaults:
gmail.com, yahoo.com, outlook.com, hotmail.com, icloud.com,
aol.com, zoho.com, protonmail.com, yandex.com, gmx.com,
mail.ru, rediffmail.com, qq.com, 163.com, 126.com, tutanota.com,
yahoo.co.jp, nifty.com
Email Format Check:
Confirms the email follows standard formatting rules (e.g., user@domain.com
).
Domain Allowlist Check: Validates that the email domain is in the allowed list.
MX Record Lookup: Retrieves the mail exchange (MX) records for the email domain.
SMTP Communication (Optional): Connects to the mail server and verifies the recipient's address.
To ensure the library is working correctly, run the test suite:
pytest tests/
The library offers two approaches to handle errors:
raise_exception=True
to raise exceptions for validation errors.errors
attribute for later inspection.Contributions are welcome! If you'd like to enhance the functionality or fix an issue, feel free to open a pull request.
This project is licensed under the MIT License.
For any issues or feature requests, please open an issue.
Happy Validating! 🎉
FAQs
DNS and SMTP Email Validator is a robust Python library designed
We found that dns-smtp-email-validator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.