https://github.com/romanzipp/laravel-mailcheck
A PHP Laravel Wrapper for the MailCheck.ai API
https://github.com/romanzipp/laravel-mailcheck
Last synced: about 1 month ago
JSON representation
A PHP Laravel Wrapper for the MailCheck.ai API
- Host: GitHub
- URL: https://github.com/romanzipp/laravel-mailcheck
- Owner: romanzipp
- License: mit
- Created: 2023-09-25T13:43:34.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-10-05T04:52:23.000Z (over 1 year ago)
- Last Synced: 2025-03-15T01:16:11.484Z (about 1 month ago)
- Language: PHP
- Homepage: https://www.mailcheck.ai
- Size: 68.4 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# Laravel MailCheck.ai
[](https://packagist.org/packages/romanzipp/laravel-mailcheck)
[](https://packagist.org/packages/romanzipp/laravel-mailcheck)
[](https://packagist.org/packages/romanzipp/laravel-mailcheck)
[](https://github.com/romanzipp/Laravel-MailCheck/actions)A Laravel Wrapper for the [MailCheck.ai](https://www.mailcheck.ai) disposable email API made by [@tompec](https://github.com/tompec).
## ✨ Migrating from Validator.Pizza
This package was previously called "Validator.Pizza". See the following guide if you want to migrate your previous installation.
Migration Guide
### **Package name**
```sh
composer remove romanzipp/laravel-validator-pizza
composer require romanzipp/laravel-mailcheck
```### **Config file**
Update the configuration file name.
```diff
- config/mailcheck.php
+ config/mailcheck.php
```### **Code references**
```diff
- romanzipp\ValidatorPizza\
+ romanzipp\MailCheck\
```### **Rule**
```diff
- 'email' => 'required|email|validator_pizza',
+ 'email' => 'required|email|disposable',
```### Table name
The default new **table name** will be `mailcheck_checks`. If you want to keep the previous `validator_pizza` table name change the entry in your config file.
```diff
- validator_pizza
+ mailcheck_checks
```## Features
- Query the [MailCheck.ai](https://www.mailcheck.ai) API for disposable Emails & Domains
- Cache responses
- Store requested domains in database## Installation
```
composer require romanzipp/laravel-mailcheck
```## Configuration
Copy configuration to your project:
```
php artisan vendor:publish --provider="romanzipp\MailCheck\Providers\MailCheckProvider"
```Run the migration:
```
php artisan migrate
```## Usage
#### Controller Validation
```php
namespace App\Http\Controllers;use Illuminate\Http\Request;
class HomeController extends Controller
{
public function handleEmail(Request $request)
{
$request->validate([
'email' => 'required|email|disposable',
]);// ...
}
}
```#### Standalone
```php
$checker = new \romanzipp\MailCheck\Checker;// Validate domain
$validDomain = $checker->allowedDomain('ich.wtf');// Validate mail address (uses domain check endpoint internally)
$validEmail = $checker->allowedEmail('[email protected]');
```## Advanced Usage
You can make your disposable checks more hard or loose by configuring the edge case behavior.
There are 3 possible outcomes to set:- `romanzipp\MailCheck\Enums\ApiIssue::ALLOW` - allow the domain/mail
- `romanzipp\MailCheck\Enums\ApiIssue::DENY` - deny the chekechecked domain/mail
- `romanzipp\MailCheck\Enums\ApiIssue::EXCEPTION` - throw a [`DisposableMailException`](src/Exceptions/DisposableMailException)### Rate Limit exceeded
```php
return [
// ...
'decision_rate_limit' => \romanzipp\MailCheck\Enums\ApiIssue::EXCEPTION,
];
```### No MX DNS records present
There is no MX DNS entry present on the checked domain which means they can not receive any messages.
```php
return [
// ...
'decision_no_mx' => \romanzipp\MailCheck\Enums\ApiIssue::EXCEPTION,
];
```### Invalid request
```php
return [
// ...
'decision_invalid' => \romanzipp\MailCheck\Enums\ApiIssue::EXCEPTION,
];
```