mirror of
https://github.com/creyD/email_valid.git
synced 2026-04-12 11:20:30 +02:00
feat: added version 0.1.0
This commit is contained in:
60
app/main.py
Normal file
60
app/main.py
Normal file
@@ -0,0 +1,60 @@
|
||||
from fastapi import FastAPI
|
||||
from validate_email import validate_email
|
||||
|
||||
# App Setup
|
||||
app = FastAPI(
|
||||
title="MailConfirm API",
|
||||
description="API for telegram bot for confirming emails.",
|
||||
version="0.1.0",
|
||||
docs_url="/",
|
||||
redoc_url=None,
|
||||
debug=False,
|
||||
swagger_ui_parameters={
|
||||
"docExpansion": "list",
|
||||
"displayOperationId": True,
|
||||
"defaultModelsExpandDepth": 5,
|
||||
"defaultModelExpandDepth": 5,
|
||||
"filter": True,
|
||||
"displayRequestDuration": True,
|
||||
"defaultModelRendering": "model",
|
||||
"persistAuthorization": True,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@app.post("/validate_email", operation_id="validate_email")
|
||||
def validate_mail(email: str) -> bool:
|
||||
"""
|
||||
Validate email address using regex.
|
||||
"""
|
||||
is_valid = validate_email(
|
||||
email_address=email,
|
||||
check_format=True,
|
||||
check_blacklist=True,
|
||||
check_dns=True,
|
||||
dns_timeout=10,
|
||||
check_smtp=True,
|
||||
smtp_timeout=10,
|
||||
|
||||
)
|
||||
return is_valid or False
|
||||
|
||||
@app.post("/validate_multiple_emails", operation_id="validate_multiple_emails")
|
||||
def validate_multiple_emails(emails: list[str]) -> dict[str, bool]:
|
||||
"""
|
||||
Validate multiple email addresses using regex.
|
||||
"""
|
||||
results = {}
|
||||
for email in emails:
|
||||
is_valid = validate_email(
|
||||
email_address=email,
|
||||
check_format=True,
|
||||
check_blacklist=True,
|
||||
check_dns=True,
|
||||
dns_timeout=10,
|
||||
check_smtp=True,
|
||||
smtp_timeout=10,
|
||||
|
||||
)
|
||||
results[email] = is_valid or False
|
||||
return results
|
||||
24
requirements.txt
Normal file
24
requirements.txt
Normal file
@@ -0,0 +1,24 @@
|
||||
filelock==3.18.0
|
||||
idna==3.10
|
||||
py3-validate-email==1.0.5.post2
|
||||
dnspython==2.7.0
|
||||
|
||||
annotated-types==0.7.0 # FastAPI
|
||||
anyio==4.9.0 # FastAPI
|
||||
fastapi==0.115.12 # FastAPI
|
||||
idna==3.10 # FastAPI
|
||||
pydantic==2.11.4 # FastAPI
|
||||
pydantic-core==2.33.2 # FastAPI
|
||||
sniffio==1.3.1 # FastAPI
|
||||
starlette==0.46.2 # FastAPI
|
||||
typing-extensions==4.13.2 # FastAPI
|
||||
typing-inspection==0.4.0 # FastAPI
|
||||
|
||||
click==8.1.7 # uvicorn server
|
||||
httptools==0.6.4 # uvicorn server
|
||||
pyyaml==6.0.2 # uvicorn server
|
||||
uvicorn==0.32.0 # uvicorn server
|
||||
uvloop==0.21.0 # uvicorn server
|
||||
watchfiles==0.24.0 # uvicorn server
|
||||
websockets==14.1 # uvicorn server
|
||||
gunicorn==23.0.0 # uvicorn server
|
||||
20
validate_mail.py
Normal file
20
validate_mail.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from validate_email import validate_email
|
||||
|
||||
# Replace with your target email
|
||||
emails =[
|
||||
"conrad@noah.tech",
|
||||
"bernd@noah.tech"
|
||||
]
|
||||
for mail in emails:
|
||||
is_valid = validate_email(
|
||||
email_address=mail,
|
||||
check_format=True,
|
||||
check_blacklist=True,
|
||||
check_dns=True,
|
||||
dns_timeout=10,
|
||||
check_smtp=True,
|
||||
smtp_timeout=10,
|
||||
|
||||
)
|
||||
|
||||
print(f"Is '{mail}' valid? -> {is_valid}")
|
||||
Reference in New Issue
Block a user