Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Mailgun Email Validation Laravel Package

arturbruno/laravel-mailgun-email-validation

Laravel validation rule that checks emails with PHP FILTER_VALIDATE_EMAIL then Mailgun’s Email Validation API. Supports role/disposable checks, mailbox verification, and strict mode to fail when Mailgun can’t be reached.

View on GitHub
Deep Wiki
Context7

Laravel Mailgun Email Validation

Laravel email validation that uses the Mailgun API for a three-step validation check.

To find examples of how validation rules can be applied in the Laravel framework, please view the validation docs

Install

Require via composer.

composer require kouz/laravel-mailgun-email-validation

For Laravel >=5.5 the package will be discoverd. For Laravel <=5.4 add package to list of service providers in config/app.php

<?php
  //config/app.php
  
    'providers' => [
        Kouz\LaravelMailgunValidation\ServiceProvider::class,
    ],

Publish and fill out the config/mailgun-email-validation.php file with your Mailgun API key.

php artisan vendor:publish --provider="Kouz\LaravelMailgunValidation\ServiceProvider"

Basic Usage

Use the following rule to validate your email fields. The rule will first check the address against PHP's FILTER_VALIDATE_EMAIL and then will call the Mailgun API.

$request->validate([
    'email' => ['required', 'mailgun_email'],
]);

Further flags can added to the rule to make the validation more strict.

$request->validate([
    'email' => ['required', 'mailgun_email:role,disposable,mailbox,strict'],
]);

Each flag if present, will add the following validation rules:

  • role Don't allow role-based addresses such as ‘admin’, ‘sales’, ‘webmaster’...
  • disposable Don't allow disposable email domains.
  • mailbox A call is made to the ESP to verify the mailboxes existence. Add strict flag to ensure that Mailgun was able to verify a mailbox and didn't return "Unknown".
  • 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.

Recommended Usage

The following configuration will try to check if the email addresses mailbox exists and is not a disposable email address. If Mailgun is not contactable or Mailgun can't perform the mailbox check, the validation will fall back on PHP's FILTER_VALIDATE_EMAIL.

$request->validate([
    'email' => ['required', 'mailgun_email:disposable,mailbox'],
]);

License

This project is licensed under a MIT License which you can find in this LICENSE.

Feedback

If you have any feedback, comments or suggestions, please feel free to open an issue within this repository.

Laravel Validation Rules

This package is part of the Laravel Validation Rules collection. If you're after more useful validation rules, head to the Laravel Validation Rules website.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope