0% found this document useful (0 votes)
3 views7 pages

Python

This document provides a step-by-step guide to install Python, required libraries, and create an email verification application using Python. It includes instructions for writing the script, saving it, and converting it into an executable file using PyInstaller. The app verifies email addresses by checking their syntax, MX records, and SMTP responses, and allows users to save the results in a CSV format.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views7 pages

Python

This document provides a step-by-step guide to install Python, required libraries, and create an email verification application using Python. It includes instructions for writing the script, saving it, and converting it into an executable file using PyInstaller. The app verifies email addresses by checking their syntax, MX records, and SMTP responses, and allows users to save the results in a CSV format.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

1.

Install Python stable release


From: https://www.python.org/downloads/windows
✅ During install, check “Add Python to PATH”

2. Install Required Libraries


Open Command Prompt and run:

bash

pip install pyinstaller dnspython

pip install pyinstaller openpyxl

3. Open Command Prompt

 Press Windows + R, type cmd, then hit Enter

 Navigate to the folder where you saved the .py file.

Example: If it's on your Desktop:

bash

cd Desktop

Or if it's in Downloads:

bash

cd Downloads

4.  Build the .exe


Navigate to the folder where you saved the script, then run:

bash

CopyEdit

pyinstaller --onefile --windowed email_verifier_app.py

 Your App is Ready


Find the final .exe inside the dist folder.

Simple Instructions to Create the Script Locally

You’ll manually create the Python file — this only takes 1 minute:

🔹 Step 1: Open Notepad

1. Press Windows + R, type notepad, and hit Enter.

🔹 Step 2: Copy & Paste the Code Below

python
CopyEdit

import tkinter as tk

from tkinter import filedialog, messagebox

import re

import dns.resolver

import smtplib

import csv

import os

import openpyxl

def is_valid_syntax(email):

pattern = r"^[\w\.-]+@[\w\.-]+\.\w+$"

return re.match(pattern, email) is not None

def has_mx_record(domain):

try:

records = dns.resolver.resolve(domain, 'MX')

return len(records) > 0

except:

return False

def smtp_check(email):

domain = email.split('@')[1]

try:

mx_records = dns.resolver.resolve(domain, 'MX')

mx_record = str(mx_records[0].exchange)

server = smtplib.SMTP(timeout=10)

server.connect(mx_record)

server.helo('example.com')

server.mail('[email protected]')

code, message = server.rcpt(email)


server.quit()

return code == 250 or code == 251

except:

return False

def read_emails(file_path):

emails = []

ext = os.path.splitext(file_path)[1].lower()

try:

if ext == '.csv':

with open(file_path, newline='', encoding='utf-8') as f:

reader = csv.reader(f)

for row in reader:

if row:

emails.append(row[0].strip())

elif ext == '.txt':

with open(file_path, 'r', encoding='utf-8') as f:

for line in f:

email = line.strip()

if email:

emails.append(email)

elif ext == '.xlsx':

wb = openpyxl.load_workbook(file_path)

ws = wb.active

for row in ws.iter_rows(min_row=1, max_col=1, values_only=True):

email = row[0]

if email:

emails.append(str(email).strip())

except Exception as e:

messagebox.showerror("Error", f"Failed to read file: {e}")

return emails
def verify_emails(file_path):

results = []

emails = read_emails(file_path)

for email in emails:

status = "Invalid Format"

if is_valid_syntax(email):

domain = email.split('@')[1]

if has_mx_record(domain):

if smtp_check(email):

status = "Valid"

else:

status = "SMTP Failed"

else:

status = "No MX Record"

results.append((email, status))

return results

def save_results(results, out_file):

with open(out_file, 'w', newline='', encoding='utf-8') as csvfile:

writer = csv.writer(csvfile)

writer.writerow(["Email", "Status"])

for row in results:

writer.writerow(row)

def start_verification():

file_path = filedialog.askopenfilename(filetypes=[("All Supported", "*.csv *.xlsx *.txt"),

("CSV files", "*.csv"),

("Excel files", "*.xlsx"),

("Text files", "*.txt")])

if not file_path:
return

messagebox.showinfo("Processing", "Email verification in progress. This may take a few


minutes...")

results = verify_emails(file_path)

out_file = filedialog.asksaveasfilename(defaultextension=".csv", filetypes=[("CSV files", "*.csv")])

if out_file:

save_results(results, out_file)

messagebox.showinfo("Done", f"Verification complete. Results saved to: {out_file}")

root = tk.Tk()

root.title("Email Verifier")

root.geometry("300x150")

label = tk.Label(root, text="Email Verifier with SMTP Check", font=("Arial", 12))

label.pack(pady=20)

btn = tk.Button(root, text="Start Verification", command=start_verification)

btn.pack(pady=10)

root.mainloop()

🔹 Step 3: Save the File

In Notepad:

 Click File → Save As

 File name: email_verifier_all_filetypes.py

 Save as type: All Files

 Encoding: UTF-8

 Location: Desktop or Downloads

🔹 Step 4: Run the App

In Command Prompt:
bash

CopyEdit

cd Desktop

python email_verifier_all_filetypes.py

Step-by-Step: Convert .py to .exe

🔹 Step 1: Open Command Prompt

Press Windows + R, type cmd, and hit Enter

🔹 Step 2: Install PyInstaller (if not already)

Run this:

bash

CopyEdit

pip install pyinstaller

🔹 Step 3: Go to the Script Folder

Use the cd command to go to the folder where you saved email_verifier_all_filetypes.py

Example:

bash

CopyEdit

cd Desktop

🔹 Step 4: Run PyInstaller to Build .exe

Use this command:

bash

CopyEdit

pyinstaller --onefile --windowed email_verifier_all_filetypes.py

✅ What this does:

 --onefile: Packs everything into one .exe

 --windowed: Hides the black terminal window (since it's a GUI app)
🔹 Step 5: Find Your .exe File

After it finishes:

 Go to the dist folder inside the script directory

 You’ll find: email_verifier_all_filetypes.exe

✅ Double-click it — your app is ready to use!

You might also like