|
| 1 | +# Laravel Validator Rules - Email Validation Mailgun |
| 2 | +A email validation that uses the [Mailgun API](https://documentation.mailgun.com/en/latest/api-email-validation.html#email-validation) for a three-step validation check. |
| 3 | + |
| 4 | +To find examples of how validation rules can be applied in the Laravel framework, please view the [validation docs](https://laravel.com/docs/5.6/validation). |
| 5 | + |
| 6 | +## Install |
| 7 | +Require via composer. |
| 8 | +``` |
| 9 | +composer require kouz/laravel-mailgun-email-validation |
| 10 | +``` |
| 11 | +For Laravel >=5.5 the package will be discoverd. For Laravel <=5.4 add package to list of service providers in config/app.php |
| 12 | +``` |
| 13 | +<?php |
| 14 | + //config/app.php |
| 15 | + |
| 16 | + 'providers' => [ |
| 17 | + Kouz\LaravelMailgunValidation\ServiceProvider::class, |
| 18 | + ], |
| 19 | +``` |
| 20 | +Publish and fill out the config/mailgun-email-validation.php file with your Mailgun API key. |
| 21 | +``` |
| 22 | +php artisan vendor:publish --provider="Kouz\LaravelMailgunValidation\ServiceProvider" |
| 23 | +``` |
| 24 | + |
| 25 | +## Basic Usage |
| 26 | +Use the following rule to validate your email fields. The rule will first check the address against |
| 27 | +PHP's [FILTER_VALIDATE_EMAIL](http://php.net/manual/en/filter.filters.validate.php) and then will call |
| 28 | +the Mailgun API. |
| 29 | + |
| 30 | +**mailgun_email:role,disposable,mailbox,strict** |
| 31 | +The field under validation must be formatted as an e-mail address. The following flags can be added to |
| 32 | +apply additional validation: |
| 33 | + |
| 34 | +* **role** Don't allow role-based addresses. |
| 35 | +* **disposable** Don't allow disposable email domains. |
| 36 | +* **mailbox** Verify mailbox. Add strict flag to ensure that Mailgun was able to verify a mailbox and didn't return "Unknown". |
| 37 | +* **strict** Always require a response from Mailgun to validate. By default if a API request fails, the validation will pass. The strict flag ensures that a Mailgun response was recieved. |
| 38 | + |
| 39 | +## License |
| 40 | +This project is licensed under a MIT License which you can find |
| 41 | +[in this LICENSE](https://github.com/TheoKouzelis/laravel-mailgun-email-validation/blob/master/LICENSE). |
| 42 | + |
| 43 | +## Feedback |
| 44 | +If you have any feedback, comments or suggestions, please feel free to open an issue within this repository. |
| 45 | + |
| 46 | +## Laravel Validation Rules |
| 47 | +This package is part of the Laravel Validation Rules collection. If you're after more useful validation rules, |
| 48 | +head to the [Laravel Validation Rules](https://laravel-validation-rules.github.io/) website. |
0 commit comments