How Abstract API Handles Email Validation in Magento
Abstract API addresses the core weaknesses of traditional methods through a server-side checkpoint that performs real-time DNS, SMTP, and provider-type checks.
- It moves beyond simple regex filters to check if a mailbox is deliverable, disposable, or a catch-all address.
- The system scores each address for quality and returns an auto-correct suggestion when it detects a likely typo.
- A single, fast REST call operates synchronously during checkout or registration to remove fraud and deliverability penalties.
- Users can reject, correct, or flag emails based on detailed information like deliverability status and disposable domain flags.
How to Add Abstract API to Your Dev Environment
Once you understand Abstract’s capabilities, it is simple to add its email validation API to your project.
- First, create an Abstract account to get your unique API key.
- From your Magento root directory, run the composer command to require the PHP email validation package.
- Store the API key securely in your environment file or Magento configuration.
- Create a custom module and register an observer for events like customer_save_before.
- Within the observer, configure the API with your key and call the verify method with the user's email.
- Use the detailed response to reject, correct, or flag the email based on your business rules.
Sample Email Validation Implementation with Abstract API
The following code shows a practical implementation within a Magento observer. It retrieves the customer's email, sends it to Abstract API for verification, and throws an exception if the address is not deliverable or comes from a disposable domain. This action prevents the creation of a customer account with a bad email.
$email = $observer->getEvent()->getCustomer()->getEmail();
\Abstractapi\EmailValidation\AbstractEmailValidation::configure(
$this->scopeConfig->getValue('dev/abstract/api_key')
);
$info = \Abstractapi\EmailValidation\AbstractEmailValidation::verify($email);
if ($info->deliverability !== 'DELIVERABLE' || $info->is_disposable_email->value) {
throw new \Magento\Framework\Exception\LocalizedException(
__('Please enter a valid email address.')
);
}The API returns a detailed JSON object. The main verdict comes from the "deliverability" field, while "quality_score" expresses confidence. Other boolean fields clarify the result, with checks for syntax, free email providers, disposable domains, MX records, and a live SMTP handshake. You can map these fields to hard rejections or soft warnings to maintain list hygiene without the loss of real customers.
{
"email":"johnsmith@gmail.com",
"deliverability":"DELIVERABLE",
"quality_score":0.9,
"is_valid_format":{"value":true,"text":"TRUE"},
"is_free_email":{"value":true,"text":"TRUE"},
"is_disposable_email":{"value":false,"text":"FALSE"},
"is_mx_found":{"value":true,"text":"TRUE"},
"is_smtp_valid":{"value":true,"text":"TRUE"}
}Final Thoughts
Traditional email validation relies on simple format checks. These methods fail to detect undeliverable or disposable addresses, which leads to high bounce rates and potential fraud. Abstract API solves this with real-time SMTP and DNS checks that confirm an email's actual validity.
To reliably validate user emails, create an account with Abstract API and get your free API key.


