Whether it comes from a user, from a remote API, or even from your database, it is necessary to validate the data's consistency for any data type.
Let's take the example of an email address that would be provided by a person who wants to subscribe to your newsletter. Logically your script will check the following elements:
These rules are sufficient for a first validation step, and are typically what an email validation regular expression (or regex) will do. Then, and since you want to make sure that the email address exists and belongs to the registering person, your script will send a message containing a confirmation link to the provided address. It is only when the person clicks on this link, which includes a secret identification key, that their subscription to your newsletter will be valid.
This system works very well, so much so that it is used by many websites, whether for newsletter subscription or account creation.
But what about historical data? After some time, users may delete their mailboxes, email services may get closed, and the emails in your database could become invalid.
You may consider that having invalid email addresses in your database is not an issue, but you will observe that the rate of invalid emails will increase over time. The direct consequence is that all your informational or promotional mailings will have a higher proportion of bouncebacks, and that's something you should be concerned about. Your emails may also have a very low open rate because they're being sent to free or disposable emails addresses.
A bounceback email is simply an email message that cannot be delivered to the recipient. The most common reason for this kind of error is that the recipient's mailbox does not exist.
But bouncebacks have a significant impact on your business: more emails will be sent back to your servers, more the reputation of your domain names and IP addresses used by your servers will suffer. There are regulations on the Internet that combat email spam, and the bounceback rate is one of their metrics.
If you do nothing about bounceback, your mail servers could be flagged as spam servers, and they would be blacklisted from a vast number of mail servers, which would ruin your emails' deliverability.
You should regularly check all the email addresses in your database. It is however unthinkable to send a verification link once a month to your users, as you did at the registration time. It is necessary to do this verification by other means.
The smart solution is to regularly pass your email addresses through an email validation API to ensure that the SMTP configuration corresponding to the email address is still correct. Abstract provides a free API that can do just that and is very easy to use, although there are many email validation and verification API's. The Abstract API can be used by any language capable of making a GET request on the Internet. Here is an example that you can use directly in your browser:
https://emailvalidation.abstractapi.com/v1/?api_key=YOU_API_KEY&email=johnsmith@gmail.com
And here is the response: