plumpboy / email-validate
A library for validating email via SMTP, extends from https://github.com/semplon/php-smtp-email-validation
v1.1.4
2021-01-08 07:52 UTC
Requires
- php: >=5.5
- egulias/email-validator: ^2.0
- swiftmailer/swiftmailer: ^6.2
This package is not auto-updated.
Last update: 2025-05-11 02:41:13 UTC
README
A Library extending https://github.com/semplon/php-smtp-email-validation
What It Does ?
Check if email address exists via SMTP.
Requirement
- php >= 5.5
Installation
- composer require plumpboy/email-validate
Usage
... use Plumpboy\EmailValidate\SMTPEmailValidator; ... // the email to validate $email = 'user@example.com'; // $email can be array('user@example.com', 'user1@example.com') // an optional sender $sender = 'user@mydomain.com'; // instantiate the class $SMTPValidator = new SMTPEmailValidator(); // turn on debugging if you want to view the SMTP transaction $SMTPValidator->debug = true; // do the validation $results = $SMTPValidator->validate($email, $sender); // view results echo $email.' is '.($results ? 'valid' : 'invalid')."\n"; // $results[$email] when there are many emails // send email? if ($results) { // or $results['user@example.com'] if you pass many emails //mail($email, 'Confirm Email', 'Please reply to this email to confirm', 'From:'.$sender."\r\n"); // send email } else { echo 'The email addresses you entered is not valid'; }
Laravel
For projects use laravel version < 5.5, add below code into config/app.php.
... 'providers' => [ ... Plumpboy\EmailValidate\EmailValidateServiceProvider::class, ... ], ...
You also can use below syntax in laravel.
$result = email_exists($emails, $sender); // use helper
... use Plumpboy\EmailValidate\EmailValidator; ... $result = EmailValidator::validate($email, $sender); // use facade
$result = \EmailValidator::validate($email, $sender); // or alias
if you do not pass param $sender, library will use config('mail.from.address')
.
Contribute
- Fork the repository and make changes on your fork in a feature branch.
- Commit messages must start with a capitalized and short summary.
- After every commit, make sure the test suite passes.
- Contributor sends pull request to release/develop branch, ask another contributor to check if possible.
- Don't push private keys, logs or any unnecessary files to git repository
- Merge when pull request got 2 OK from contributors and CI build is green.
- Merge develop to master to release final version.