mailboxvalidator/mailboxvalidator-yii MailboxValidator Yii framework extension to validate an email by using MailboxValidator API.

MailboxValidator Yii Email Validation Extension

  1. Installation
  2. Dependencies
  3. Methods
  4. Usage
  5. Errors
  6. Copyright

MailboxValidator Yii Email Validation Extension provides an easy way to call the MailboxValidator API which validates if an email address is valid.


Install this extension by using Composer:

`composer require mailboxvalidator/mailboxvalidator-yii`


An API key is required for this module to function.

Go to to sign up for FREE API plan and you'll be given an API key.

After you get your API key, open your `config/params.php` and add the following line into the array:


You can also set you API key in controller after calling library. Just do like this:

$mbv = new SingleValidation('PASTE_YOUR_API_KEY_HERE');

or like this:

['email', MailboxValidator::className(), 'option'=>'YOUR_SELECTED_OPTION','api_key'=>'PASTE_YOUR_API_KEY_HERE',],


Below are the methods supported in this library.

Method Name Description
validateEmail Return the validation result of an email address. Please visit MailboxValidator for the list of the response parameters.
validateFree Check whether the email address is belongs to a free email provider or not. Return Values: True, False
validateDisposable Check whether the email address is belongs to a disposable email provider or not. Return Values: True, False


Form Validation

To use this library in form validation, first call this library in your model like this:

use MailboxValidator\MailboxValidator;

After that, in the function rules, add the new validator rule for the email:

['YOUR_EMAIL_FIELD_NAME', MailboxValidator::className(), 'option'=>'disposable,free',],

In this line, the extension is been called, and you will need to specify which validator to use. The available validators are disposable and free. After that, refresh you form and see the outcome.

Email Validation

To use this library to get validation result for an email address, firstly load the library in your controller like this:

use MailboxValidator\SingleValidation;

After that, you can get the validation result for the email address like this:

$mbv = new SingleValidation(Yii::$app->params['mbvAPIKey']);
$results = $mbv->FreeEmail('');

To pass the result to the view, just simply add the $results to your view loader like this:

return $this->render('YOUR_VIEW_NAME', ['results' => $results]);

And then in your view file, call the validation results. For example:

echo 'email_address = ' . $results->email_address . "<br>";

You can refer the full list of response parameters available at here.


error_code error_message
100 Missing parameter.
101 API key not found.
102 API key disabled.
103 API key expired.
104 Insufficient credits.
105 Unknown error.


Copyright (C) 2018 by,

0 0
1 follower
Yii Version: 2.0
License: MIT
Category: Validation
Developed by: MailboxValidator
Created on: Dec 6, 2018
Last updated: a year ago
Packagist Profile
Github Repository

Related Extensions