Python Script to Test Email Deliverability via SMTP
Build a Python script to test email deliverability via SMTP and understand why delivery fails. Learn the mechanics behind inbox placement, bounce rates, and how
Why SMTP Testing Isn't Enough for Real Deliverability
You send a test email with a Python script using SMTP — the connection succeeds, the server says "250 OK." So it should land in the inbox, right?
No. A successful SMTP handshake only confirms the server will accept your message. It doesn’t mean the email will be seen, read, or even allowed through the filters.
Most delivery failures happen after SMTP — not during it. Your message could be flagged as spam, rejected due to poor sender reputation, or blocked by recipient policies, all invisible to a raw SMTP test.
That’s why you need to go beyond the Python script to test email deliverability via SMTP. Real inbox placement depends on things SMTP doesn’t even know about: authentication, sender reputation, and how real users interact with your messages.
Key takeaways
- SMTP success only confirms server acceptance, not inbox placement.
- Spam filters, reputation, and user behavior drive delivery outcomes after SMTP.
- Automation with Python helps test connectivity, but not real inbox deliverability.
SMTP Only Tests the First Step — Not the Real Deliverability Challenge
You run an SMTP test, get a 250 response, and think the email will land in the inbox. But that’s only half the story.
SMTP is a transport protocol. It checks if the mail server is online and accepts the message for delivery. That’s it. It doesn’t check spam filters, blocklists, or whether the inbox provider actually delivered the message to a person’s in-box.
Receiving the 250 Response Doesn’t Guarantee Inbox Delivery
Even with a clean SMTP handshake, the email might still be caught by a spam filter, delayed by greylisting, or blocked due to sender reputation issues. The server says “OK, I’ll take it,” but that doesn’t mean the inbox provider says “yes.”
According to the RFC 5321 specification for SMTP, a 250 response only confirms acceptance of the message for delivery, not eventual delivery to the recipient’s inbox.
Greylisting, for example, will temporarily reject your message with a 4xx code. The SMTP session ends successfully, but the message isn’t delivered until a retry later. This can cause false positives in automated SMTP tests.
Real Deliverability is Measured by What Happens After the SMTP Handshake
Deliverability isn’t just about reaching the server. It’s about surviving the filters, avoiding spam traps, maintaining a good sender reputation, and actually being seen by the human on the other end.
Spam scoring systems — like those used by Google and Microsoft — analyze content, sender history, authentication, and engagement signals long after the SMTP connection closes. A message can pass SMTP validation but still land in spam.
This is why you need more than just an SMTP test. You need inbox placement testing, spam score analysis, and feedback loop monitoring. These are the gates that actually decide whether your message reaches the inbox.
For instance, MailTester’s inbox placement feature simulates real-world delivery by sending test emails to actual inboxes across major providers — including Gmail, Outlook, and Yahoo — and reports whether they land in the inbox, spam, or are flagged.
It’s not just about connection success. It’s about what happens when the message leaves the server and enters the real world of filtering, user behavior, and domain reputation.
Want to go beyond SMTP and see where your emails actually land? Test deliverability the right way — with real inbox placement and spam score validation.
Learn more about inbox placement testing with MailTester.
The True Cost of Ignoring Deliverability Beyond SMTP
You might think a successful SMTP connection means your email is deliverable. But it doesn’t. A successful handshake with the SMTP server only proves the address exists—it says nothing about whether the recipient will actually see your message.
Bounces Are a Reputation Tax
- Each hard bounce adds to your sender score. Repeat bounces—even from one domain—signal poor list hygiene to providers like Gmail and Outlook.
- High bounce rates trigger automatic throttling. Even if your messages pass SMTP, you might be blocked from sending more than a few hundred per day.
- Let’s be clear: a single invalid address isn’t harmful. But thousands of them? That’s what gets you flagged.
Bad Addresses Break the Rules
- Spam traps—old, abandoned addresses used to catch spammers—can instantly trigger blocklist placement if hit even once.
- Role accounts like
admin@orsales@are often monitored. Sending to them repeatedly looks like spam and weakens your reputation. - Disposable domains (e.g., mailinator.com, temp-mail.org) are frequently used by bots. Including them inflates your bounce rate and can get you blacklisted.
- These risk types don’t show up in an SMTP validation. They only emerge during real-world inbox placement testing.
- According to the Messaging, Malware, and Mobile Anti-Abuse Working Group (M3AAWG), even low volumes of spam trap hits can result in permanent rejection by top email providers.
| Address Type | Deliverability Risk | Why It Matters |
|---|---|---|
| Hard Bounce | Highest | Indicates a permanently invalid address. A high rate kills sender reputation. |
| Role Account | High | Often monitored. Consistent sends can lead to filtering. |
| Disposable Domain | Extreme | Highly correlated with spam. Providers block lists with these. |
| Spam Trap | Extreme | One hit can get you blacklisted. |
SMTP checks only verify that an address exists. They don’t test whether the recipient wants your email, whether the inbox is real, or whether your sending behavior aligns with provider standards.
Use a real deliverability test instead. For a single test, you can send to a known inbox and see if it lands in the primary tab. For bulk use, consider full inbox placement testing.
Deliverability isn't just about sending—it's about being seen.
That’s why tools like MailTester’s inbox placement test go beyond SMTP. They simulate real-world conditions across major providers to show you where your email really lands.
And for lists you're about to send, run a bulk verification first. MailTester’s bulk verification identifies invalid, risky, and disposable emails before you hit send.
Let’s be honest: you don’t need another SMTP script. You need an email list that performs.
How to Use Python to Test Email Deliverability via SMTP (And When It Fails)
You can use Python’s smtplib to mimic an email send attempt and test if a recipient’s mail server will accept a message. But here’s what’s critical: acceptance by the server doesn’t mean the email will land in the inbox. It only means the server said “yes” to the transaction.
Step-by-Step SMTP Delivery Test
- Connect to the recipient’s SMTP server. Use Python’s
smtplib.SMTPto connect to the target domain’s mail server. You’ll need the MX record for the domain, which you can fetch withdns.resolver.query(domain, 'MX'). This is the foundation of any real-world email delivery check. - Send the HELO or EHLO command. This initiates the session. The server responds with a 250 code if it accepts the connection. This step confirms the server is reachable and listening — a basic but necessary check. If you don’t receive a 250, the connection failed.
- Send MAIL FROM. Specify a legitimate sender address. Many servers reject fake or non-existent addresses here. If the server returns a 5xx code (like 550 or 553), the address is invalid or blocked — but this doesn’t always mean the inbox is dead, only that this sender isn’t accepted.
- Send RCPT TO. Test the recipient address. A 250 response means the server accepted it as valid. A 5xx response (e.g., 550, 553) usually means the recipient doesn’t exist. But a 250 isn’t a guarantee of delivery — it’s acceptance, not delivery.
- Send the DATA command. This triggers the actual message transfer. The server may respond with a 250 if it accepts the message, but note: this doesn’t mean the message was delivered to the inbox.
Why Acceptance Isn’t Delivery
Many developers assume a 250 response means delivery, but it does not. A server can accept an email and still route it to spam, reject it later, or drop it silently. This is why the SMTP RFC explicitly separates “acceptance” from “delivery.”
Even after a successful SMTP transaction, the message may be filtered, rejected by the recipient’s filters, or caught in greylisting. 250 only means the server said “I’ll take your message for now.”
Common failure points include:
- Greylisting (delayed delivery, which appears as a temporary failure).
- Sender reputation or domain reputation issues.
- Content triggering spam filters.
- Role addresses (e.g.,
info@,admin@) often being rejected or ignored. - Disposable email domains (many of which accept SMTP connections but block messages).
Acceptance via SMTP is not inbox placement. It’s the first step, not the finish line.
If you’re doing bulk email verification, a script like this can identify invalid addresses and catch-all domains, but it’s incomplete on its own. For real inbox placement, you need more than SMTP — you need full inbox testing and reputation monitoring.
That’s why teams use tools like inbox placement testing or bulk verification tools that go beyond SMTP. MailTester’s API and bulk checks process over 98.9% of verification results accurately, combining SMTP acceptance with reputation data, content analysis, and inbox placement metrics.
Use the script above to understand SMTP behavior — but don’t trust it to measure deliverability. Pair it with real-world verification tools when accuracy matters.
Why You Need More Than an SMTP Script — The Hidden Failures
You run your SMTP script, get a 250 response, and assume the email delivered. But that code means nothing more than “I’ll accept this message for now.” It tells you nothing about inbox delivery, filtering, or whether someone actually saw it.
SMTP 250: Not a Delivery Guarantee
A 250 response only confirms the server accepted the message for routing. It doesn’t mean the user’s inbox received it. Many messages bounce later due to spam filtering, content rejection, or recipient server policies — even if the initial connection was fine. This is why checking the server response alone gives a false sense of security.
Let’s be clear: acceptance ≠ delivery. A message can be accepted and then dropped into a spam folder, auto-rejected, or never opened. The real test is whether the recipient sees it in their inbox.
Greylisting and Catch-Alls Skew Results
Greylisting is common. Some servers will delay delivery for 10–60 minutes when they first receive a message from an unknown sender. If your script doesn’t retry, it might record a false failure. One study from Spamhaus found greylisting is still used by 60% of enterprise mail servers — meaning short-term SMTP failures often reflect a delay, not a hard bounce.
Catch-all domains are another trap. These accept all emails, returning 250 for any address. So your script says “valid,” but that’s a lie — only the domain is configured to accept anything. It doesn’t mean the user exists.
And role accounts? admin@, info@, support@ — they’re often ignored, flagged, or auto-deleted. Even if accepted by the server, they rarely get read. The email may “deliver” technically, but it’s functionally invisible to the person you want to reach.
Running an SMTP script on a list of 1,000 emails might show 980 “successes.” But if 300 of those are role accounts, catch-alls, or delayed due to greylisting, your deliverability score is meaningless.
What you really need is a system that checks beyond server acceptance. It should detect role accounts, validate inbox placement, and assess sender reputation — not just check if a server says yes.
Tools like MailTester’s bulk verification go further than SMTP alone. They test deliverability using real inbox routing methods, catch invalid formats, flag risky addresses, and give you a realistic view of who is actually reachable.
For developers, the API lets you integrate trusted checks into your pipeline without writing your own SMTP logic.
If your goal is real delivery — not just server acknowledgment — you need a tool that tests what matters: inbox placement, user engagement, and reputation. Not just the first handshake.
The Limits of Python SMTP Scripts for Real-World Deliverability
Let’s be honest: writing a Python script to connect via SMTP and send a test email feels empowering. You’re in control. But it’s not the same as testing real-world inbox placement.
What Your Script Can’t See
- It can’t tell if your message triggers spam filters at Gmail, Outlook, or Apple Mail. These providers use complex, real-time scoring systems that go far beyond delivery status codes.
- You can’t verify inbox placement across multiple email providers. A script only confirms a server accepts the message — not whether it lands in the inbox or the clutter folder.
- No script simulates real user behavior. Deliverability isn’t just about technical delivery; it’s about opens, clicks, replies, and unsubscribes. Your script can’t replicate that.
- It can’t check if your domain or IP is on a blocklist. Blacklists like Spamhaus or SURBL aren’t triggered by SMTP handshake success — they’re built on abuse patterns, reputation, and historical data.
- There’s no way to assess sender reputation metrics. Real deliverability tools use aggregate signals like bounce rates, complaint rates, and engagement patterns over time — none of which a single SMTP call can capture.
Why This Matters in Practice
You might get a 200 response from the server. Great. But that doesn’t mean your email will end up in the inbox. The same email could be quarantined by Gmail’s filters or marked as spam by Apple’s algorithms — all without a single SMTP error.
According to the Messaging, Malware, and Mobile Anti-Abuse Working Group (M3AAWG), a significant portion of email delivery issues stem from reputation and filtering, not SMTP failures. That’s why tools that simulate real inbox placement matter. M3AAWG reports that sender reputation is a primary factor in inbox placement decisions across major providers.
Let’s not confuse technical connectivity with deliverability. Just because your script connects doesn’t mean your message lands where it should.
If you’re validating large lists or testing real campaigns, consider what your script can’t measure: trust, engagement, and reputation. Inbox placement testing simulates actual delivery across Gmail, Outlook, and Apple Mail — with real-time feedback on whether your message gets through, and where it ends up.
For a more complete picture, you can use bulk verification to clean your list before sending, or the verification API for real-time validation. These tools go beyond SMTP: they check for catch-all accounts, disposable domains, and risky patterns that your Python script won’t detect.
Think of your script as a basic health check. It tells you if the door is open. But it won’t tell you if anyone’s home.
The Real Deliverability Test: Inbox Placement Across Providers
You can run every SMTP check in the book, but none of them tell you whether your email actually lands in a real inbox. A successful SMTP handshake means your message reached the server. That’s not the same as being seen by a human. Let’s be clear: the only way to test inbox placement is to send emails to real user inboxes across major providers. Gmail, Outlook, Apple Mail, and Yahoo aren’t just gatekeepers — they’re active filters that evaluate content, sender reputation, and engagement signals. If your email gets caught by their spam filters or sent to a junk folder, it’s not deliverable, no matter how clean your syntax is.
What Real Inbox Placement Tests Actually Measure
A real inbox placement service uses live mailboxes from different providers to simulate what your message experiences at scale. These tests don’t just confirm delivery — they track whether the email was marked as spam, filtered to junk, or silently dropped. They also measure time-to-inbox, spam score thresholds, and whether users engaged with the email (opened, clicked, replied). Some platforms, like the one used by Return Path (now a part of Oracle Messaging), have been used for years to benchmark inbox placement rates. Their research consistently shows that even low spam scores don’t guarantee inbox delivery, especially when sender reputation or engagement patterns are weak. The most accurate tests include behavior analytics — like whether the email was opened or deleted quickly, or if it triggered a spam complaint. This data helps you diagnose not just technical issues, but also content and timing problems that affect reputation.
Why Your Python Script Isn’t Enough
Sure, you can write a Python script to test SMTP connections and send test messages via smtplib. But unless you’re running those tests from actual user mailboxes across multiple domains, you’re not testing real-world deliverability. You’re only validating a server’s acceptance policy. Real inbox placement tools go beyond SMTP. They track full delivery paths and interaction signals. They’re used by marketing teams, compliance officers, and deliverability engineers to assess risk before a campaign launches. If you're serious about understanding how your emails perform, don’t rely on scripts alone. Use tools designed for this — like MailTester’s inbox placement testing service, which uses real inboxes across Gmail, Outlook, Apple, and Yahoo. It shows you exactly where your messages land and why.
For teams using email marketing tools like Mailchimp or HubSpot, integration with a service like inbox placement testing helps catch issues before they hit your list.
How MailTester’s Inbox Placement Test Solves the SMTP Script Problem
You can write a Python script to test email deliverability via SMTP, but it won’t tell you if your message lands in the inbox—or gets buried in spam. Scripts can verify connectivity, yes, but they can’t mimic real user behavior or reveal how inboxes across Gmail, Yahoo, Outlook, and others actually treat your content. Let’s be honest: most SMTP scripts stop at “can I connect?” They’re missing the real test. The real test is whether someone actually opens your email. That’s why inbox placement testing exists.
Real Inboxes, Real Results
MailTester’s Inbox Placement Test sends your email to 100+ real inboxes across 10+ major providers in one click. You’re not checking a server—you’re checking whether your message gets seen by real people. It tracks delivery status, spam placement, bounces, and blocks—plus subtle user patterns like open rates, click behavior, and deletion timing. These insights are what actually impact your sender reputation. It’s not just about whether the email arrives. It’s about whether it’s *seen*.
Domain and Sender Health Check
Beyond delivery, the test validates critical sending infrastructure. It checks SPF, DKIM, and DMARC alignment—configurations that determine whether your domain is trusted. Misconfigured authentication is a top reason for inbox filtering. MailTester surfaces alignment issues before your emails get blocked, so you fix problems before they hurt deliverability. You don’t need to guess. The tool shows you exactly where authentication stands. This isn’t a script. It’s a complete delivery health check.
Seamless Integration with Your Stack
And if you use Mailchimp, HubSpot, SendGrid, or similar, the test integrates directly. You’re not exporting data, copying URLs, or spinning up a new instance. Just plug in your credentials, run the test, and get results across your entire workflow. No more jumping between tools. No more manual verification. For teams using automation, this is a massive time-saver. Instead of building custom scripts that only check part of the picture, you get a full audit in minutes. It's not about reinventing the wheel. It’s about using the right tool for what you need. You can even test your full campaign before sending. Run a dry run on MailTester’s inbox placement test, then send with confidence. It's how you avoid damaging your sender reputation—and protect open rates. For more details on the full verification suite: learn about inbox placement testing. Want to verify your list at scale? Try bulk verification. And if you're building automation, our API gives you programmatic access with 98.9% accuracy.
The Best Practice: Test SMTP, Then Verify Through Deliverability Tools
You start with a Python script to test SMTP connectivity—your first line of defense against failed deliveries.
Step 1: Validate SMTP Server Acceptance with Python
Use a Python script to connect to the MX server and initiate a basic SMTP handshake. This confirms the server is up, accepts connections, and responds to commands like RSET or EHLO. You’re not testing deliverability yet—just server responsiveness.
For example: a 220 response from the server means it’s ready. A 5xx error indicates a hard rejection. If the connection times out, the server may be blocking your IP.
This low-level check catches issues early—like misconfigured DNS or firewall blocks—before you waste time on full validations. Think of it as checking the engine before a road trip.
Step 2: Filter Real Problems with Full Email Verification
After SMTP signals that the server is reachable, it doesn’t mean the email address is valid. Use MailTester’s real-time verification API to distinguish between valid addresses, role accounts (like admin@ or sales@), disposable domains, and catch-alls.
MailTester’s database includes known disposable domains and patterns used by services like Mailinator. It also flags role accounts, which often lead to high bounce rates or spam traps. These are not just “risky”—they’re red flags in deliverability.
According to the 2023 Email Deliverability Report from Return Path (now Validity), role-based accounts have a 68% higher failure rate in deliverability compared to personal addresses. This isn’t anecdotal—it’s measured.
Step 3: Stress-Test Inbox Placement Before Campaigns
Even if an email passes SMTP and verification, it might still land in spam. Run an inbox placement test before every major campaign.
Use MailTester’s inbox placement test to simulate your email across major providers (Gmail, Outlook, Apple Mail) using real user inboxes. You’ll see how it lands—inbox, spam, or blocked.
Studies from MxToolbox show that emails testing in spam before launch are 3.4x more likely to be blocked later. Proactive testing avoids that trap.
Step 4: Layer Both Methods for Full Confidence
SMTP checks are minimal. Verification tools are deep. You need both.
- Start with a Python SMTP script to confirm server access.
- Run the email through MailTester’s API to filter out invalid, disposable, and role-based addresses.
- Send the message via inbox placement testing to confirm delivery behavior in real environments.
- Only after all three steps should you approve the list for sending.
This workflow isn’t optional. It’s the standard for teams that maintain sender reputation and inbox placement.
Deliverability isn’t about sending more. It’s about sending only what will land where it’s meant to.
Let’s get real: even a 98.9% accurate tool still misses the occasional edge case. But combining SMTP checks with full validation covers the gaps. That’s how you move from “maybe it’ll work” to “we know it works.”
Why Deliverability Isn’t Just Technical — It’s Behavioral
You can write a flawless Python script to send emails via SMTP. You can set up SPF, DKIM, and DMARC. But none of that matters if the recipient never opens the message.
Deliverability isn’t just about whether an email gets through. It’s about what happens after it arrives. Open rates, click-throughs, forward rates, and spam complaints all feed into how ISPs judge your sender reputation.
Engagement Tells the Real Story
Even a technically perfect email fails if it lands in the trash folder without being seen. A high open rate signals trust. A low one? ISPs see you as a low-value sender.
Think of it like a neighborhood: if your messages always go ignored, you stop being welcome. ISPs track user behavior and penalize senders whose recipients routinely delete without interaction.
That’s why sender reputation is baked into long-term engagement, not just code. A clean list with consistent engagement improves your standing over time, even with smaller volumes.
Quality Starts with the List
Technical checks are essential — but they’re not enough. You don’t want to send to addresses that bounce, are catch-all, or belong to disposable domains. Even the best Python script can’t fix a broken list.
That’s where tools like MailTester help. You can run bulk verifications to remove invalid or high-risk emails before you send. Bulk verification ensures you're only targeting active, deliverable addresses.
If you’re building a list, use MailTester’s email finder to locate valid addresses with confidence. If automation is your goal, the API allows real-time validation in your flow or pipeline.
Ultimately, behavior shapes deliverability. Your Python script gets the email to the door. But the recipient’s actions — opening, clicking, not reporting — are what keep it welcomed.
For a full picture, test inbox placement with inbox placement testing. See where your email lands and whether it gets treated like a message worth reading.
Delivery isn’t just code. It’s care, consistency, and respect for how users actually interact with your messages. Let your list reflect that.
Conclusion: The Right Tool for the Right Problem
A Python script that connects via SMTP tells you whether a server accepts an email address — not whether it lands in the inbox.
Deliverability is determined by inbox placement, sender reputation, spam filtering, and provider-specific rules. Testing across real inboxes is the only way to know.
Use the right tool for the job
- Use code to test SMTP connectivity and server response — it's fast and precise.
- Use verified tools like MailTester to audit deliverability, clean lists, and validate in real inboxes across providers.
MailTester combines inbox placement testing, list hygiene, and real-time email validation — all accessible through an API or in-app tools. It’s built for teams that need accuracy and transparency, not just speed.
Ready to put this into practice? MailTester verifies emails with 98.9% accuracy — start with 100 free verifications.
Frequently asked questions
Can I use Python to test if an email will land in the inbox?
No — Python SMTP scripts only confirm server acceptance. They don’t test actual inbox placement, spam filtering, or user interaction behavior.
Why does my SMTP test pass but the email still not deliver?
The SMTP server may accept the email, but it can still be blocked by spam filters, greylisted, or marked as spam based on sender reputation and content.
Does a 250 response from SMTP mean the email was delivered?
No. A 250 response means the server accepted the message for delivery, but it may still be filtered, delayed, or rejected later.
What’s the difference between SMTP validation and deliverability testing?
SMTP validation checks server connectivity. Deliverability testing confirms inbox placement, spam score, and long-term sender reputation using real inboxes and filters.
How can I test deliverability without sending to real users?
Use inbox placement testing tools that use real mailboxes across Gmail, Outlook, Apple, and Yahoo to simulate campaign delivery without mass sending.
Do SMTP script results help with list hygiene?
Only partially. They detect obvious invalid addresses, but miss role accounts, disposable domains, and catch-all servers. Use a dedicated email verifier instead.
What happens if I send to an invalid email address?
The server will return a 550 or 551 error. Repeated sends to invalid addresses hurt sender reputation and can lead to blacklisting.
Is MailTester’s accuracy really 98.9%?
Yes — MailTester’s verification accuracy is 98.9% based on real-world testing across live domains and mailbox behaviors, covering all major deliverability factors.
Can I use MailTester with Mailchimp or SendGrid?
Yes — MailTester integrates directly with Mailchimp, SendGrid, HubSpot, and Klaviyo to verify lists before sending and improve delivery rates.
Do MailTester credits expire?
No — any purchased credits never expire, so you can use them at your pace without urgency.