Validate the list of email addresses
- PHP >= 7.4
$ composer require konstantin-dmitrienko/email-validator
<?php
use KonstantinDmitrienko\EmailValidator\Email\Email;
use KonstantinDmitrienko\EmailValidator\File\File;
require 'vendor/autoload.php';
// Load file with list of emails
$emails = File::getLinesFromFile('emails.txt');
// Filter valid emails only
$validEmails = Email::validateEmails($emails);
// Save valid emails in a new flle
File::putLinesInFile($validEmails, 'valid-emails.txt');