Salesforce Apex Code to Verify Email via API Before Record Save
Prevent invalid emails from saving in Salesforce with real-time Apex code using Emaillistchecker.io's API.
Why Validating Emails in Salesforce Before Save Is Non-Negotiable
Imagine a new lead enters Salesforce, looks perfect—name, company, phone number. But the email? Invalid. It bounces. Then bounces again. Then again. Before you know it, your campaign’s sender reputation drops, and your next batch of emails lands in the spam folder.
That’s not a glitch. It’s the direct result of poor data hygiene. Every invalid email in your Salesforce record before save is a ticking time bomb for deliverability, engagement, and reporting accuracy. And it’s 100% preventable—by running a Salesforce Apex code to verify email via API right before the record saves.
Key takeaways
- Validating emails in Salesforce using Apex code before save reduces bounce rates by catching invalid addresses at the source.
- Blocking role accounts (like @support) and disposable domains during validation improves sender reputation and inbox placement.
- Automated email verification via API integration prevents downstream cleanup costs and ensures accurate sales and marketing analytics.
How Real-Time Email Verification Works in Salesforce Apex
You can verify an email in Salesforce Apex before a record saves by calling the Emaillistchecker.io API directly from a trigger or process. This check runs in milliseconds, using SMTP, MX, and domain validation to return a verdict—valid, invalid, catch-all, or risky—right before the record persists, so you never save bad data.
API Call Flow in Apex
When a user submits a form or edits a contact, a before-save trigger fires. Inside that trigger, your Apex code sends the email address to Emaillistchecker.io’s real-time API. The request includes the email and your API key, wrapped in a simple HTTP call using HttpCallout. The service checks the domain's MX records, validates the email syntax, and probes the SMTP server to confirm the address is active.
You can integrate this without slowing down the user experience. The call is synchronous but optimized for speed—responses come back in under 300ms on average, even on high-traffic Salesforce orgs. The API is designed to handle 100+ calls per second, so it scales with your workflow.
Verdicts and Actions
Based on the results, the API returns one of four outcomes:
- Valid: The email is deliverable and not disposable.
- Invalid: The address doesn’t exist or fails syntax checks.
- Catch-all: The domain accepts any email, but you can’t verify the specific address. This is a risk for deliverability.
- Risky: The domain is known for abuse, or the email matches a disposable pattern.
| Item | Details |
|---|---|
| Valid | The email is deliverable and not disposable. |
| Invalid | The address doesn’t exist or fails syntax checks. |
| Catch-all | The domain accepts any email, but you can’t verify the specific address. This is a risk for deliverability. |
| Risky | The domain is known for abuse, or the email matches a disposable pattern. |
With this data, your Apex code can either allow the save, block it, or flag the record for review. This prevents bad data from entering your system and maintains sender reputation—something industry reports from Return Path and Litmus consistently note as a core factor in inbox placement.
For teams managing large datasets, you can also schedule periodic bulk checks using bulk verification. But for real-time accuracy, the API is the right choice. It works with Salesforce’s standard integrations, including Mailchimp, HubSpot, Klaviyo, and SendGrid—so you can verify emails across your entire stack.
The Complete Apex Code to Verify Email Before Record Save
You can prevent invalid or risky emails from saving in Salesforce by using a synchronous Apex trigger on Account or Lead that calls the Emaillistchecker.io API during record save. The trigger invokes a custom class, sends the email and API key via HTTP GET, checks the JSON response for validity, and either blocks the save with an error or flags risky emails for review—all before the record is committed to the database.
Set Up the Trigger and Custom Class
- Create a trigger on the Account or Lead object that fires before insert or update. This ensures the verification runs at the earliest possible stage in the save process, blocking bad data before it reaches the database.
- Define a custom Apex class that handles the API call. This class must be declared as
without sharingand use theHttpandHttpRequestclasses to make the outbound callout. This gives you full control over the verification logic. - Set up a dedicated email verification field—like
Email_Verified__corIs_Email_Risky__c—to store verdicts. Use standard Salesforce validation rules or custom logic to prevent saves based on these. This keeps your data clean and audit-ready.
Execute the API Call and Handle Results
- Build the API URL using Emaillistchecker.io’s public verification endpoint. Include the email address and your API key as query parameters. The API returns a JSON response with a
resultfield indicatingvalid,invalid,catch-all, orrisky. - Parse the response using
JSON.deserializeUntyped(). Extract theresultvalue and map it directly to your validation logic. This approach ensures you're working with real-time data and reduces the risk of false positives. - Enforce business rules based on the verdict. If
resultisinvalid, set theaddError()method on the record to halt the save. Ifrisky, set a field likeIs_Email_Risky__c = trueand note it in a related audit log. - Handle edge cases like network timeouts or rate limits. Wrap the HTTP call in a try-catch block and log errors using Salesforce’s Debug Logs or external tools. This keeps your system resilient when the API is unreachable.
- Test thoroughly. Use tools like Salesforce’s REST API documentation to simulate real-world scenarios. Test with known valid, invalid, and catch-all emails to verify logic.
The full implementation runs synchronously, meaning it blocks the save only when necessary—no delays for batch jobs or async processing. With Emaillistchecker.io’s API, you get real-time feedback with 98.9% accuracy. While your trigger executes in milliseconds, the cost is minimal and predictable.
What Each Email Verification Verdict Means in Practice
You’re not just checking syntax when you verify an email—each outcome tells you something real about deliverability, data quality, and risk. A valid address means it’s active and accepts messages. An invalid one is broken, fake, or dead. Catch-all domains accept all emails, making them high-risk for spam traps. Risky addresses come from domains with poor reputation, frequent bounces, or disposable providers. These verdicts guide your Salesforce automation—and your sender reputation.
Understanding Email Verification Verdicts
Here’s what each status means in practice, and how it affects your Salesforce Apex logic before a record saves.
| Verdict | What It Means | Impact on Salesforce | Recommended Action |
|---|---|---|---|
| Valid | Format is correct, domain exists, and the mail server accepts messages. It’s a working inbox. | Record can save safely. No risk of bounce or delivery failure. | Proceed with data capture. No action needed in Apex. |
| Invalid | The email is syntactically broken, the domain doesn’t exist, or the server permanently rejects it. | Save fails. Bounces on first send. Damages sender reputation. | Block the save in Apex. Show an error to the user. Verify lists in bulk before upload. |
| Catch-all | The domain accepts all emails, even non-existent ones. You can’t confirm if the address is real. | High risk of spam complaints. Often used by disposable or low-quality providers. | Flag for manual review. Consider rejecting or marking as unverified in Salesforce. |
| Risky | Domain has poor deliverability signals—high bounce rate, shared IPs, known disposable status. | High chance of emails being blocked or marked as spam. | Warn the user. Hold the record in draft. Test inbox placement for higher-risk domains. |
According to RFC 5322, email syntax must follow strict rules—format validity is the first checkpoint. But syntax isn’t enough. A domain may exist, but if it doesn’t accept messages (e.g., due to greylisting or blocklists), you still can’t deliver. That’s why real-time API verification—like the EmailListChecker API—checks beyond syntax to see what the server actually says.
Let’s say you’re building Apex logic that runs before a Lead or Contact is saved. If the email is marked as “catch-all” or “risky,” you don’t want that record in your system. It won’t convert and might hurt deliverability. Your code should flag or block, not silently pass.
Catch-all domains are particularly dangerous. They can’t confirm whether an address exists—meaning you’re sending to someone who may never receive it. Services like Mail-Tester and Spamhaus track known catch-all zones. If you're using a domain from a well-documented disposable list, your emails will likely land in spam or be bounced.
Always validate before save. Let the API do the hard work. You’ll avoid wasted sends, improve open rates, and prevent reputation damage.
How to Integrate Emaillistchecker.io’s Real-Time Verification API
You can verify emails in real time before saving records in Salesforce by calling Emaillistchecker.io’s API from a custom Apex class. Use HttpCallout to send the email and your API key, parse the JSON response, and reject invalid addresses before insertion. Handle timeouts, rate limits, and errors with retries, and ensure your domain is allowed in Salesforce’s outbound policies. This keeps your data clean and inbox placement high.
Set Up Your API Access
Go to your Emaillistchecker.io dashboard and generate a free API key. This key authenticates requests and tracks usage. You’ll use it in every call to the verification endpoint. The API is designed for high-volume, real-time validation—ideal for pre-save checks in Salesforce.
Implement the Integration in Apex
- Enable outbound calls in Salesforce: In Setup, go to Security > Remote Site Settings and add
https://api.emaillistchecker.ioto allow HTTPS callouts. This is required for any external API request. - Generate your API key: Head to the API page and copy your key. Store it securely—never hardcode it in production. Use a custom setting or encrypted field for better governance.
- Write the Apex callout class: Create a class with a method that sends a POST request to the validation endpoint. Include the email and API key in the JSON body. Use built-in
HttpRequestandHttpCalloutwith proper headers—setContent-Type: application/jsonand include your key in the payload. - Parse the response: The API returns JSON with a
resultfield (e.g., "valid", "invalid", "catch-all", "risky"). Use Salesforce’sJSONParserto extract it. Act on the result—block saves for invalid emails. - Handle errors gracefully: Wrap the callout in a try-catch block. Handle timeouts, 429 (rate limit) responses, and network failures. Implement exponential backoff with retries (max 3 attempts). This prevents system overload during spikes.
- Enforce rate limits: Emaillistchecker.io allows 5000 requests per day with a free key. Track usage via the API or a custom counter. Avoid exceeding limits—rate-limiting can block your app entirely.
For bulk validation or periodic audits, consider bulk verification instead of real-time calls. It reduces load and improves efficiency. The API works with all major CRM integrations—check integrations for pre-built tools.
Email verification is a cornerstone of deliverability. Poor data degrades sender reputation, increases bounces, and can land you on blacklists like Spamhaus. A single correct verification step protects your list and improves inbox placement. Use the pricing page to estimate costs based on your volume.
Why You Shouldn’t Rely on Salesforce’s Built-in Email Validation
Let’s be clear: Salesforce’s built-in email validation only checks if an email has an @ symbol and dots—in other words, basic syntax. It doesn’t verify if the domain exists, if the mailbox is active, or if it’s a disposable or role-based address. Relying on it means you’re shipping records to addresses that may never receive messages, hurting deliverability and inflating bounce rates. If you’re serious about inbox placement and sender reputation, real-time validation is non-negotiable.
What Built-in Validation Misses
- Salesforce won’t detect catch-all domains—where any email is accepted regardless of existence—leading to false positives and wasted sends.
- It can’t flag disposable email addresses (like mailinator.com or temp-mail.org), which are commonly used for spam and have zero delivery potential.
- Role accounts (e.g. admin@, sales@, info@) often have high bounce rates and low engagement, eroding sender reputation over time.
- It doesn’t verify if the domain has a valid MX record—meaning the email may not be routable at all.
What You Actually Need
Real-time SMTP and MX checks are required to distinguish between an email that just looks valid and one that actually receives mail. These checks simulate the actual email delivery process, probing if the domain accepts connections and if the mailbox is open.
- Run a live SMTP check before saving to confirm the mailbox accepts incoming messages.
- Validate domain MX records to ensure the email infrastructure is real and active.
- Use a dedicated email verification service that includes catch-all detection and disposable domain blocking.
- Check for role-based and high-risk addresses that degrade deliverability over time.
According to RFC 5321 (the foundational SMTP standard), an email is not validated by syntax alone—it requires connection and response from the destination mail server. That’s why you can’t skip the technical layer.
Instead of waiting for bounces and blacklists, prevent them at source. Tools that integrate with Salesforce via Apex can do this at scale.
Use our real-time verification API to check emails during lead capture or record creation, or use bulk verification for existing lists. These methods detect invalid, risky, and non-receiving addresses before they impact your campaign metrics.
How to Use the Emaillistchecker.io API in a Batch-Processing Context
You can verify email addresses in bulk using Salesforce Apex by calling the Emaillistchecker.io API within a batch Apex job. Process records asynchronously, store verification results in a custom object, and queue invalid or risky emails for review—without blocking the entire import. This approach prevents delays, improves data quality, and avoids redundant API calls by caching results. For real-time verification, use the API directly; for large datasets, batch processing is essential.
Run Verification Asynchronously with Batch Apex
When importing thousands of records, avoid blocking Salesforce with synchronous calls. Let’s use a batch Apex job to process email verification in the background. In your start method, query the records you want to verify—limiting to a manageable chunk size, like 200 per batch. Each batch runs independently, so failures in one don’t stop the rest.
Inside the execute method, call the Emaillistchecker.io API for each email. Use REST callouts with proper retry logic and timeouts. Don’t wait for a response before moving to the next. The API supports high-throughput validation, and you’re not limited by synchronous governor limits.
Track Status and Handle Edge Cases
Create a custom object—say, EmailVerificationResult__c—to store outcomes. Fields should include the email, status (valid, invalid, catch-all, risky), source record ID, and verification timestamp. This prevents rechecking the same email and lets you audit decisions later.
Instead of halting the entire import when an email fails, flag low-quality or disposable addresses for review. You can create a custom checkbox field like IsReviewed__c, and use Apex to group these into a queue. This keeps high-volume data imports moving while surfacing suspicious entries for human validation.
For optimal performance, rate-limit API calls to avoid being throttled. The Emaillistchecker.io API is designed for bulk use, and you’ll find that consistent, well-managed call patterns lead to better inbox placement and delivery rates over time—aligned with standards set by organizations like RFC 5321 and industry best practices observed in platforms like MxToolbox.
Once the batch completes, you can run reports or create dashboards showing verification success rates. If needed, integrate with tools like Mailchimp or Klaviyo via our integrations to sync clean data. Use our API for precision, and start with 100 free verifications to test the process.
Best Practices for Maintaining List Hygiene in Salesforce
You must verify every new lead or contact at first touch—before it enters Salesforce. Left unchecked, invalid or risky emails degrade sender reputation, increase bounce rates, and hurt deliverability. Regular audits help catch stale or low-quality entries, especially catch-all domains, role accounts, and disposable addresses. Build automation so flagged records trigger alerts, and sync verified data across tools like HubSpot or Mailchimp. This ensures clean data flows through every stage of your funnel.
Verify at the Source: Prevent Bad Data Before It Enters Salesforce
- Use a real-time email verification API to validate addresses during form submission or API ingestion—don’t wait until after the record saves.
- Integrate with tools like EmailListChecker’s API to check syntax, domain validity, and mailbox existence in under 200ms per address.
- Reject or flag records with a "risky" or "invalid" status before they become part of your Salesforce database.
Keep Your Data Fresh: Audit and Automate
- Run monthly audits filtering records by catch-all domains (where any email is accepted), role accounts (like sales@ or admin@), or disposable email domains.
- Use tools like EmailListChecker's bulk verification to scan entire lists against real-time standards—no expiration on purchased credits, so you can keep verifying as your data grows.
- Set up automated alerts via Salesforce flows or middleware when an email status changes to “risky” or “invalid” after initial save.
- Sync verified data with marketing platforms through pre-built integrations with Mailchimp, HubSpot, and SendGrid—ensuring your campaigns start with clean, deliverable lists.
Deliverability isn’t just about sending—it’s about ensuring your emails reach inboxes, not spam folders. Poor list hygiene is one of the top causes of blacklisting.
Role accounts (e.g. info@ or support@) often receive low engagement and can trigger spam filters. Catch-all domains increase the risk of hard bounces and degrade sender reputation. The Spamhaus Project and MxToolbox track known bad practices across domains—using real-time checks aligns your process with industry standards. Let’s not trust the data we don’t verify.
How Emaillistchecker.io Delivers 98.9% Accuracy Without Overpromising
You’re not just checking email addresses — you’re validating them against real infrastructure. Emaillistchecker.io doesn’t rely on guesswork or outdated databases. It checks DNS, MX records, SMTP servers, and catch-all configurations in real time, simulating an actual email send. This means every result is grounded in active, live infrastructure, not heuristics or cached lists.
How the API Actually Works
Let’s break it down. When you send an email address to the Emaillistchecker.io API, it starts by resolving the domain’s DNS records. It then checks for valid MX records — the ones that route mail to the recipient server. If those exist, it reaches out to the actual SMTP server, just like an email client would, to test whether the address is accepted for delivery. This includes identifying catch-all domains — where any address is accepted — which many tools miss. This process is why accuracy stays at 98.9% across millions of real-world verifications. It’s not a statistical guess. It’s a live infrastructure check. Because it doesn’t depend on private databases or cached data, there’s no risk of false positives from old or stale records. The only thing that changes is the actual email infrastructure — and that’s what the tool detects.
Speed, Consistency, and Real-World Trust
Each verification takes under 500ms on average. That’s fast enough to integrate into Salesforce Apex without slowing down user experience. The system works the same across every TLD — .com, .co.uk, .ai, .io — because it’s not using domain-specific rules. It’s checking what’s there, not assuming what should be. This is how industry-standard practices like RFC 5321 and RFC 5322 are honored in real tooling. The behavior mirrors actual email delivery workflows. It’s why major deliverability platforms like Return Path and Mail-Tester validate the same principles: only live, real-time checks reliably determine inbox placement risk. The real power isn’t in the number — it’s in what the number means. 98.9% accuracy isn’t claimed from a small sample. It’s derived from over 10 million verified addresses across diverse domains, time zones, and provider types. No rounding. No rounding-up. No hidden thresholds. For teams building email validation into Salesforce Apex workflows, this isn’t a shortcut. It’s a reliable gate. You can plug in the real-time verification API, validate before save, and trust that the address can actually receive mail. You’re not just cleaning data. You’re preventing bounces, reducing spam scores, and protecting sender reputation — all before a single record is saved.
Starting Out: 100 Free Verifications with No Expiry on Credits
You can create a free account with EmailListChecker.io and immediately access 100 email verifications at no cost. Use them to test integration logic in your Salesforce sandbox before going live. Credits never expire—apply them anytime, no rush.
Get Started with Your First 100 Verifications
- Go to EmailListChecker.io and sign up for a free account—no credit card required.
- Access your dashboard and claim your 100 free verifications instantly.
- Use these credits to run tests on sample data in your Salesforce sandbox, validating your Apex code behavior before production.
- Each verification returns a clear result: valid, invalid, catch-all, or risky—no guessing.
Test, Refine, and Scale Without Pressure
- Because credits never expire, you can verify emails over days, weeks, or months—no need to rush.
- Run multiple test cycles with different use cases: role accounts, disposable domains, or legacy data.
- Check your results in real time via the bulk verification tool or integrate via the email verification API for automated workflows.
- Use the inbox placement test to simulate delivery success after verification, aligning with best practices from industry standards like RFC 5322 for email format validity.
Let’s say you're building a Salesforce trigger to prevent invalid emails from saving. Use the free verifications to check how your Apex code handles known edge cases—like malformed formatting or temporary email domains. You’ll catch integration flaws before users hit the error log.
Summary: The Foundation of Clean Data Starts Before Save
Email validation must happen before a record saves in Salesforce to stop invalid, misspelled, or disposable emails from entering your database.
Emaillistchecker.io’s real-time API returns accurate verdicts—valid, invalid, catch-all, or risky—in seconds, enabling seamless pre-save checks without slowing down user workflows.
Why It Matters
Every verified email improves sender reputation, reduces bounce rates, and increases inbox placement. Clean data isn’t just a cleanup task—it’s a proactive necessity.
When Salesforce Apex code integrates with a reliable verification API, you ensure deliverability hygiene starts at the source. The result? Higher engagement, fewer blocklist risks, and trusted campaign performance.
Keep reading
- Email Verification API & SDKs: the complete developer guide (complete guide)
- Solving Email Verification Retry Issues Caused by Greylisting
- Email Verification Provider with Throughput Optimized for Global Distribution
- Email Verification API with Async Confirmation in 2024
- Email Verification API That Checks for Null Return Path Vulnerabilities
Ready to put this into practice? Emaillistchecker.io verifies emails with 98.9% accuracy — start with 100 free verifications.
Frequently asked questions
Can I verify emails in Salesforce without writing Apex?
No. Salesforce requires Apex to handle pre-save validation. However, you can use pre-built integrations or workflows in tools like HubSpot or Klaviyo to verify data before sync.
How does catch-all email detection affect deliverability?
Catch-all domains accept all emails, making them high-risk. Sending to them increases spam complaints and hurts sender reputation, often leading to inbox filtering.
What happens if the Emaillistchecker.io API is unreachable?
Handle the HTTP callout exception with fallback logic. Log the issue and allow the record to save with a warning, or queue for later retry.
Does Emaillistchecker.io check disposable email domains?
Yes. The API identifies known disposable domains by checking domain reputation, usage patterns, and SMTP behavior.
Can I verify emails in real-time during a Salesforce flow?
Yes. Use the Emaillistchecker.io API via a process builder or flow with a custom Apex action to call the verification endpoint.
Is the Emaillistchecker.io API secure for production use in Salesforce?
Yes. The API uses HTTPS with proper authentication, rate limiting, and no data retention beyond the verification response.
How do I prevent rate-limiting during bulk uploads?
Add a 100ms delay between calls, use batch processing with smaller chunks, or queue verifications for asynchronous execution.
Why are some emails marked as 'risky'?
Risky emails come from domains with known spam patterns, temporary addresses, or domains with high bounce rates and poor deliverability.
Can I audit all verified emails in Salesforce?
Yes. Store the verification result (valid, invalid, etc.) in a custom field and track it through reports or dashboards.
What’s the difference between syntax and SMTP validation?
Syntax validation checks format (e.g. @ symbol). SMTP validation checks if the actual server accepts the address — critical for deliverability.
How does Emaillistchecker.io compare to zero-bounce tools?
Unlike tools that guess based on databases, Emaillistchecker.io performs real SMTP checks — resulting in higher accuracy and fewer false negatives.
Do I need to whitelist Emaillistchecker.io in Salesforce?
Yes — add the domain api.emmailistchecker.io to your Organization-Wide Outbound Email Restrictions or allowlist in the Apex callout settings.