承接 mailboxvalidator/mailboxvalidator-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mailboxvalidator/mailboxvalidator-bundle

Composer 安装命令:

composer require mailboxvalidator/mailboxvalidator-bundle

包简介

Symfony bundle that used MailboxValidator API to validate email in form.

README 文档

README

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 on

Note: 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:

$ composer require mailboxvalidator/mailboxvalidator-bundle

Dependencies

An API key is required for this module to function.

  1. Go to https://www.mailboxvalidator.com to sign up for FREE API plan if you do not have an API key.

  2. (If you are at Symfony 4) After obtained your API key, load a .env file in your PHP application via Dotenv::load().

use Symfony\Component\Dotenv\Dotenv;

$dotenv = new Dotenv();
$dotenv->load(__DIR__.'/.env'); //Your .env file path
  1. 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

Before using the validator, be sure to add the bundle into the config/bundles.php file:

// config/bundles.php
return [
    ...
    MailboxValidatorBundle\MailboxValidatorBundle::class => ['all' => true],
];

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, Disposable Email API and Free Email API.

  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:
use MailboxValidatorBundle\Validator\MBVSingle;
use MailboxValidatorBundle\Validator\MBVDisposable;
use MailboxValidatorBundle\Validator\MBVFree;
  1. 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:
->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-2026 by MailboxValidator.com

统计信息

  • 总下载量: 5
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-11-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固