Whether you’re managing a web portal, registering users, or sending newsletters, how to detect affiliate program fraud essential that your email verification is top-notch. Without it, your marketing campaigns can fail miserably due to non-existent and invalid email addresses. In this article, we’ll show you how to verify and validate emails with PHP code to keep your lists safe from spammers and fake users.
The in-built filter_var( ) function in PHP can validate an email address for basic syntax checks and existence verification, like a valid ‘@’ symbol and the presence of a domain part. However, it’s not able to detect invalid characters such as the underscore ‘_’ or internationalized domain names (IDN). To solve this, you can use a custom regex pattern that matches an email and excludes those characters.
Detecting Browser Spoofing with Device Fingerprinting
If you want to go a step further, you can implement an API that uses SMTP validation to check the authenticity of an email address. This is a more advanced approach that’s more accurate than the in-built email verification function and can detect a large number of invalid email addresses that appear to be correctly formatted but actually do not exist.
This API is simple to implement and requires only the definition of a class called EmailValidation, an instance of this class, and an API key. The API key is configured in the class as the private method withPHPFIlter( ). The API call is made from the getRequest() method of this class, which is invoked when an input email is provided.