项目作者: overint

项目描述 :
Validate email address with Mailgun's validation service (Syntax checks, DNS validation, MX validation)
高级语言: PHP
项目地址: git://github.com/overint/php-mailgun-validation.git
创建时间: 2016-12-29T05:57:40Z
项目社区:https://github.com/overint/php-mailgun-validation

开源协议:MIT License

下载


php-mailgun-validation

Validate email address with Mailgun’s validation service (Syntax checks, DNS validation, MX validation)
You can view Mailgun’s blog post about the service here: http://blog.mailgun.com/free-email-validation-api-for-web-forms/
An API key is required to use this library, it can be obtained from mailgun’s site after signup:
https://mailgun.com/app/account/security

The service is free, however fair usage limits do apply (detailed in the post linked above).
Mailgun no longer offers this service for free, however this library works fine with the new paid service.

Installing using Composer

You can install this package using composer:

  1. composer require overint/php-mailgun-validation

Example Use Case

  1. <?php
  2. require 'vendor\autoload.php';
  3. use overint\MailgunValidator;
  4. $validator = new MailgunValidator('your-mailgun-public-key');
  5. echo var_dump($validator->validate('test@example.com')); //bool(false)
  6. echo var_dump($validator->validate('someuser@gmail.com')); //bool(true)
  7. echo var_dump($validator->validate('someuser@hotmail.com')); //bool(true)
  8. echo var_dump($validator->validate('someuser@aol.com')); //bool(true)
  9. echo var_dump($validator->validate('misformed@domain')); //bool(false)
  10. echo var_dump($validator->validate('invalid@anonexistingdomain.com')); //bool(false)
  11. echo var_dump($validator->validateExtended('someuser@ymail.com'));
  12. object(stdClass)#207 (8) {
  13. ["address"]=> string(18) "someuser@ymail.com"
  14. ["did_you_mean"]=> NULL
  15. ["is_disposable_address"]=> bool(false)
  16. ["is_role_address"]=> bool(false)
  17. ["is_valid"]=> bool(true)
  18. ["mailbox_verification"]=> string(4) "true"
  19. ["parts"]=> object(stdClass)#208 (3) {
  20. ["display_name"]=> NULL
  21. ["domain"]=> string(9) "ymail.com"
  22. ["local_part"]=> string(8) "someuser"
  23. }
  24. ["reason"]=> NULL
  25. }