apavliukov / laravel-email-smtp-validation
Validate email address via SMTP to check if it really exists
Installs: 7 111
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^7.4|^8.0
- illuminate/support: ^8.0|^9.0|^10.0|^11.0
- zytzagoo/smtp-validate-email: ^1.0
Requires (Dev)
- fakerphp/faker: ^1.23
- mockery/mockery: ^1.6
- orchestra/testbench: ^6.19
- phpunit/phpunit: ^11.0.1
README
Laravel package for simpler usage of zytzagoo/smtp-validate-email package to check if email really exists. It retrieves MX records for the email domain and then connects to the domain's SMTP server to try figuring out if the address really exists.
Installation
composer require apavliukov/laravel-email-smtp-validation
Usage
Config
You can copy config file
php artisan vendor:publish --tag=email-smtp-validation-config
If you want to disable SMTP check on some environments, you can pass them in config on key disable_on_env
. By default, local
env is disabled to allow you to use fake emails during development.
Rule
For example, in your request class you can use Rules\EmailSmtpVerified
rule like here
use AlexPavliukov\EmailSmtpValidation\Rules\EmailSmtpVerified;
...
class ValidateEmailRequest extends FormRequest
{
public function rules()
{
return [
'email' => [
'required',
'email',
app(EmailSmtpVerified::class),
],
];
}
}