Mailkeker.py Instant
def check_email(email, password): domain = email.split('@')[1] try: # Basic MX lookup simulation (in real scripts, this uses dnspython) # Connecting to the domain's SMTP server server = smtplib.SMTP(f'smtp.domain', 587, timeout=TIMEOUT) server.starttls() # Secure the connection
The second stage verifies that the domain of the email address exists and has properly configured Mail Exchange (MX) records. MX records are DNS entries that specify which mail servers are responsible for receiving email on behalf of the domain. If a domain has no MX records, it's incapable of receiving email.
MailKeker.py is an open-source Python script that allows you to verify email addresses in bulk. It uses a combination of techniques, including DNS checks, SMTP checks, and syntax validation, to determine whether an email address is valid or not. The tool is designed to be easy to use, fast, and efficient, making it an excellent solution for email marketers, developers, and anyone looking to validate email addresses. MailKeker.py
Email validation is not just a technical nicety; it's a critical component of any successful email marketing or communication strategy. Here's why:
import os import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from email.mime.base import MIMEBase from email import encoders class MailKeker: def __init__(self): # Load configurations safely from environment variables self.server = os.getenv("SMTP_SERVER") self.port = int(os.getenv("SMTP_PORT", 587)) self.user = os.getenv("EMAIL_USER") self.password = os.getenv("EMAIL_PASSWORD") def send_email(self, to_email, subject, body, attachment_path=None, is_html=False): # Create the container email message msg = MIMEMultipart() msg['From'] = self.user msg['To'] = to_email msg['Subject'] = subject # Attach the body text or HTML layout msg_type = 'html' if is_html else 'plain' msg.attach(MIMEText(body, msg_type)) # Handle file attachments if present if attachment_path and os.path.exists(attachment_path): filename = os.path.basename(attachment_path) with open(attachment_path, "rb") as attachment: part = MIMEBase("application", "octet-stream") part.set_payload(attachment.read()) encoders.encode_base64(part) part.add_header( "Content-Disposition", f"attachment; filename= filename", ) msg.attach(part) # Execute the secure SMTP connection try: with smtplib.SMTP(self.server, self.port) as server: server.starttls() # Upgrade connection to secure TLS server.login(self.user, self.password) server.sendmail(self.user, to_email, msg.as_string()) print(f"Success: Email successfully sent to to_email") return True except Exception as e: print(f"Error sending email: e") return False if __name__ == "__main__": # Instant initialization block for quick testing keker = MailKeker() keker.send_email( to_email="recipient@example.com", subject="MailKeker Automation Test", body=" def check_email(email, password): domain = email
[ Data Source / Config ] ➔ [ MIME Constructor ] ➔ [ TLS Connection ] ➔ [ SMTP Dispatch ] 2. Setting Up the Development Environment
[ Raw Email List ] │ ▼ ┌─────────────────────────────────┐ │ Step 1: Syntax Check │ ──(Invalid Structure)──► [ Discard / Log Error ] └─────────────────────────────────┘ │ (Passed) ▼ ┌─────────────────────────────────┐ │ Step 2: MX Record Lookup │ ──(No MX Found)────────► [ Flag Dead Domain ] └─────────────────────────────────┘ │ (Active Server) ▼ ┌─────────────────────────────────┐ │ Step 3: SMTP Verification │ ──(User Unknown)───────► [ Mark as Invalid ] └─────────────────────────────────┘ │ (250 OK Received) ▼ [ Validated Deliverable Email ] 1. Regex and Syntax Parsing MailKeker
class MailKeker: def (self, smtp_server: str, smtp_port: int, username: str, password: str, use_tls: bool = True): self.smtp_server = smtp_server self.smtp_port = smtp_port self.username = username self.password = password self.use_tls = use_tls