Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mailboxvalidator/mailboxvalidator-bundle
MailboxValidator Symfony bundle enable users to block disposal email, detect free email and validate if an email is valid
https://github.com/mailboxvalidator/mailboxvalidator-bundle
email-checker email-validation email-validator email-verification mailboxvalidator-api mailboxvalidator-bundle symfony symfony-bundle
Last synced: about 1 month ago
JSON representation
MailboxValidator Symfony bundle enable users to block disposal email, detect free email and validate if an email is valid
- Host: GitHub
- URL: https://github.com/mailboxvalidator/mailboxvalidator-bundle
- Owner: MailboxValidator
- License: mit
- Created: 2019-11-29T01:34:36.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-01-02T02:31:35.000Z (11 months ago)
- Last Synced: 2024-10-12T23:05:21.560Z (about 1 month ago)
- Topics: email-checker, email-validation, email-validator, email-verification, mailboxvalidator-api, mailboxvalidator-bundle, symfony, symfony-bundle
- Language: PHP
- Homepage: https://www.mailboxvalidator.com/
- Size: 22.5 KB
- Stars: 3
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: license.txt
Awesome Lists containing this project
README
# MailboxValidator Symfony Email Validation Bundle
MailboxValidator Symfony Email Validation Bundle enables user to easily validate if an email address is valid, a type of disposable email or free email.
This bundle can be useful in many types of projects, for example
- to validate an user's email during sign up
- to clean your mailing list prior to email sending
- to perform fraud check
- and so onNote: This bundle only support Symfony 4.3 and onwards.
## Installation
We recommend the installation via Composer. Open the terminal, navigate to your project root and run the following commands:
```console
$ composer require mailboxvalidator/mailboxvalidator-bundle
```## Dependencies
An API key is required for this module to function.
1. Go to [https://www.mailboxvalidator.com](https://www.mailboxvalidator.com/plans#api) to sign up for FREE API plan if you do not have an API key.
2. After obtained your API key, load a ``.env`` file in your PHP application via ``Dotenv::load()``.
```php
use Symfony\Component\Dotenv\Dotenv;$dotenv = new Dotenv();
$dotenv->load(__DIR__.'/.env'); //Your .env file path
```3. Open your ``.env`` file and add the following line:
```
MBV_API_KEY=PASTE_YOUR_API_KEY_HERE
```Notes: You need to install the MailboxValidator PHP Module in order to use this bundle. You can visit https://github.com/MailboxValidator/mailboxvalidator-php for the source codes.
## Usage
The validators available to validate the email are: single, free and disposable. Each validator validate the email by using MailboxValidator API. For more information, you can visit [Single Validation API](https://www.mailboxvalidator.com/api-single-validation), [Disposable Email API](https://www.mailboxvalidator.com/api-email-disposable) and [Free Email API](https://www.mailboxvalidator.com/api-email-free).
1. To use any one of three validators or use all of the validators, include the following lines in any form controller that handle the validation:
```php
use MailboxValidatorBundle\Validator\MBVSingle;
use MailboxValidatorBundle\Validator\MBVDisposable;
use MailboxValidatorBundle\Validator\MBVFree;
```2. After that, add a new rule to your form field. For example, if you want to validate the disposable email, your rule will be like this:
```php
->add('email', EmailType::class, [
'constraints' => [
new MBVDisposable([
//You can also custom a message yourself. For example,
//'message' => 'This email is disposable. Please enter another email again.',
]),
],
])
```## Copyright
Copyright (C) 2024 by MailboxValidator.com