Why You Shouldn't Just "Send"⚠️
Let's start with the problem. Many developers build scripts that send emails directly — without verifying if the address is even real. This might seem harmless at first, but over time, it causes serious issues:
- High bounce rates: Emails sent to fake or mistyped addresses won't go through. A high bounce rate signals to providers that you're a spam risk.
- Wasted resources: Your system spends time and processing power trying to deliver undeliverable messages.
- Damaged sender reputation: Internet Service Providers (ISPs) track your domain's behavior. Sending to invalid addresses frequently can get you blacklisted.
- Spam folder trouble: Even your valid recipients may stop seeing your emails because providers begin flagging you.
✅ Best practice: Always verify your email list before sending. And that's where AbstractAPI steps in.

✅ Step 1: Validate Emails with AbstractAPI
Let's first make sure our emails are legitimate and deliverable. AbstractAPI's Email Validation API gives us real-time feedback on an email address's status — checking syntax, domain, and even whether the mailbox exists using SMTP checks.
🔌 How it Works
Here's a Python function that sends a request to AbstractAPI and determines if an email is valid:
import requests
ABSTRACTAPI_KEY = 'your_abstractapi_key_here'
def is_email_valid(email):
url = f"https://emailvalidation.abstractapi.com/v1/?api_key={ABSTRACTAPI_KEY}&email={email}"
response = requests.get(url)
data = response.json()
# Check if SMTP and deliverability checks passed
smtp_valid = data.get("is_smtp_valid", "FALSE")
deliverability = data.get("deliverability", "UNDELIVERABLE")
return smtp_valid == "TRUE" and deliverability == "DELIVERABLE"
🔍 What This Does
- Calls AbstractAPI's validation endpoint with the email you want to check.
- Parses the response for two key fields:
- is_smtp_valid: Whether the mailbox exists and accepts messages.
- deliverability: AbstractAPI's overall rating based on multiple factors.
- Returns True only if both indicate the email is likely to be successfully delivered.
🛡️ Why it matters: This tiny check protects your domain, improves deliverability, and keeps your email campaigns clean and effective.
Want to explore more validation capabilities? Check out our full Email Verification Guide.
📤 Step 2: Sending Emails with Python's smtplib
Now that we've cleaned up our list, let's look at how to send an email using Python's standard libraries.
Python includes two helpful modules for sending emails: smtplib (for sending) and email.message (for formatting). Together, they let you craft and dispatch messages with minimal setup.
✉️ Basic Example:
import smtplib
from email.message import EmailMessage
def send_email(sender, recipient, subject, body, smtp_server, smtp_port, login, password):
msg = EmailMessage()
msg["From"] = sender
msg["To"] = recipient
msg["Subject"] = subject
msg.set_content(body)
# Connect to SMTP server and send the email
with smtplib.SMTP_SSL(smtp_server, smtp_port) as server:
server.login(login, password)
server.send_message(msg)
🛠️ What You'll Need
- SMTP credentials: For example, Gmail requires you to enable App Passwords if you use 2FA.
- Server details: For Gmail, use smtp.gmail.com and port 465 (SSL).
- Basic message data: From, to, subject, and body.
🧩 Step 3: Put It All Together – Validate & Send
Here's a complete script that:
- Loops through a list of emails.
- Validates each one.
- Sends only to the verified addresses.
import smtplib
import requests
from email.message import EmailMessage
ABSTRACTAPI_KEY = 'your_abstractapi_key_here'
def is_email_valid(email):
url = f"https://emailvalidation.abstractapi.com/v1/?api_key={ABSTRACTAPI_KEY}&email={email}"
response = requests.get(url)
data = response.json()
smtp_valid = data.get("is_smtp_valid", "FALSE")
deliverability = data.get("deliverability", "UNDELIVERABLE")
return smtp_valid == "TRUE" and deliverability == "DELIVERABLE"
def send_email(sender, recipient, subject, body, smtp_server, smtp_port, login, password):
msg = EmailMessage()
msg["From"] = sender
msg["To"] = recipient
msg["Subject"] = subject
msg.set_content(body)
with smtplib.SMTP_SSL(smtp_server, smtp_port) as server:
server.login(login, password)
server.send_message(msg)
# Your email list
email_list = ["valid@example.com", "fake@nowhere.com"]
# Email credentials and message
smtp_server = "smtp.gmail.com"
smtp_port = 465
sender_email = "your_email@gmail.com"
password = "your_app_password"
subject = "Hello from Python!"
body = "This is a test email sent via Python and AbstractAPI 🎉"
# Send to only valid emails
for email in email_list:
if is_email_valid(email):
send_email(sender_email, email, subject, body, smtp_server, smtp_port, sender_email, password)
print(f"✅ Email sent to {email}")
else:
print(f"❌ Skipping invalid email: {email}")
🎯 Final Thoughts
Sending emails with Python is simple — but sending them effectively requires a bit more care.
By combining the convenience of Python's built-in smtplib with the power of AbstractAPI's Email Validation, you can create a robust, reliable, and professional email system that follows industry best practices.
✨ Validate before you send — and enjoy cleaner lists, fewer bounces, and better results.

🔗 Explore More AbstractAPI Email Tools:
Frequently Asked Questions
What Python libraries do you need to send email?
Python's standard library includes everything you need to get started: smtplib handles the SMTP connection to your mail server, and email.message.EmailMessage lets you compose the message itself. For calling a third-party validation API before sending, you can add the requests library, which is not part of the standard library but is widely available.
How do you send email securely with Python using Gmail?
Use smtplib.SMTP_SSL with port 465 to open an encrypted SSL connection to Gmail's SMTP server. If your Gmail account has two-factor authentication enabled, you must generate an App Password in your Google account settings and use that instead of your regular password — Gmail will reject your normal credentials over SMTP.
Why should you validate an email address before sending with Python?
Sending to invalid or non-existent addresses causes bounces, and a high bounce rate signals to ISPs that you may be a spammer, damaging your domain's sender reputation. Validating first — checking both SMTP validity and deliverability — means you only attempt delivery to addresses that are likely to accept mail, keeping your bounce rate low and your domain off blacklists.
What is the difference between SMTP validity and deliverability when validating emails?
SMTP validity confirms that the email address is formatted correctly and that the mail server for the domain actually exists and responds. Deliverability goes a step further and checks whether the mailbox itself will accept incoming messages — an address can be syntactically valid and have a live mail server but still be configured to reject mail. Checking both before sending gives you the most reliable signal that delivery will succeed.
How do you send email to multiple recipients in Python without exposing all addresses?
Pass a list of addresses to the To field of EmailMessage to send to multiple recipients in a single call. If you want each recipient to see only their own address (rather than the full list), send individual messages in a loop, one per recipient. Combining this with a pre-send validation step — looping through each address and skipping invalid ones — prevents wasted SMTP calls and protects your sender reputation.
When should you use an email validation API instead of a regex check in Python?
A regex check only verifies that an address looks correctly formatted — it cannot tell you whether the domain has a working mail server or whether the mailbox actually exists. An email validation API like AbstractAPI performs live SMTP and DNS checks in real time, catching invalid or undeliverable addresses that a regex would accept. Use an API validation step whenever reliable delivery matters, such as transactional emails, signup flows, or bulk outreach campaigns.



