Installation:
composer require veeqtoh/laravel-active-email
Run migrations (if applicable) and publish the config:
php artisan vendor:publish --provider="Veeqtoh\ActiveEmail\ActiveEmailServiceProvider"
First Use Case: Add the validation rule to a form request or controller:
use Veeqtoh\ActiveEmail\Rules\ActiveEmail;
$request->validate([
'email' => ['required', new ActiveEmail],
]);
Where to Look First:
config/active-email.php for default settings.app/Rules/ActiveEmail.php (if extended) or the package’s Rules directory.test@example.com) to verify behavior.Form Requests:
public function rules()
{
return [
'email' => ['required', 'email', new \Veeqtoh\ActiveEmail\Rules\ActiveEmail],
];
}
Controller Validation:
$validator = Validator::make($request->all(), [
'email' => ['required', new \Veeqtoh\ActiveEmail\Rules\ActiveEmail],
]);
Dynamic Customization: Pass options to the rule:
new ActiveEmail(['strict' => true, 'blacklist' => ['mailinator.com']])
API Responses: Return consistent error messages:
$request->validate([
'email' => [new ActiveEmail, 'message' => 'Only active emails are allowed.'],
]);
RegistersUsers trait to include the rule in registration.ActiveEmail::fake() in tests to mock validation:
ActiveEmail::shouldBlock('test@example.com');
Performance:
strict mode sparingly in high-traffic apps.config/active-email.php to set a TTL for cached responses:
'cache_ttl' => 60, // Cache for 60 minutes
False Positives:
whitelist option to exclude known-safe domains:
new ActiveEmail(['whitelist' => ['company.com']])
API Dependencies:
'fallback' => true, // Use local lists if API fails
Rate Limits:
'debug' => env('ACTIVE_EMAIL_DEBUG', false),
php artisan cache:clear
strict: true enforces real-time API checks (bypasses cache).mailinator.com).new ActiveEmail([
'blacklist' => ['temp-mail.org'],
'greylist' => ['10minutemail.com'],
])
Custom Providers: Override the default API provider by binding a new implementation:
$this->app->bind(
\Veeqtoh\ActiveEmail\Contracts\EmailValidator::class,
\App\Services\CustomEmailValidator::class
);
Local Lists:
Extend the Blacklist or Whitelist classes to load from a database:
class DatabaseBlacklist implements \Veeqtoh\ActiveEmail\Contracts\Blacklist {
public function isBlacklisted(string $domain): bool {
return DB::table('blocked_domains')->where('domain', $domain)->exists();
}
}
Event Hooks:
Listen for active-email.blocked events to log or notify:
Event::listen(\Veeqtoh\ActiveEmail\Events\EmailBlocked::class, function ($event) {
Log::warning("Blocked email: {$event->email}");
});
How can I help you explore Laravel packages today?