Overview

Namespaces

  • Crunchmail
    • Collections
    • Entities
    • Exception
    • PHPUnit
    • Resources

Classes

  • Crunchmail\Client
  • Crunchmail\Collections\GenericCollection
  • Crunchmail\Entities\AttachmentEntity
  • Crunchmail\Entities\ContactEntity
  • Crunchmail\Entities\ContactListEntity
  • Crunchmail\Entities\ContactQueueEntity
  • Crunchmail\Entities\DomainEntity
  • Crunchmail\Entities\GenericEntity
  • Crunchmail\Entities\MessageEntity
  • Crunchmail\Entities\RecipientEntity
  • Crunchmail\PHPUnit\IsEntityConstraint
  • Crunchmail\PHPUnit\IsGenericCollectionConstraint
  • Crunchmail\PHPUnit\IsGenericEntityConstraint
  • Crunchmail\PHPUnit\IsGenericResourceConstraint
  • Crunchmail\PHPUnit\IsResourceConstraint
  • Crunchmail\PHPUnit\TestCase
  • Crunchmail\Resources\DomainsResource
  • Crunchmail\Resources\GenericResource
  • Crunchmail\Resources\PreviewSendResource

Exceptions

  • Crunchmail\Exception\ApiException
  • Overview
  • Namespace
  • Class
 1: <?php
 2: /**
 3:  * Domains resource
 4:  *
 5:  * @author    Yannick Huerre <dev@sheoak.fr>
 6:  * @copyright 2015 (c) Oasiswork
 7:  * @license   https://opensource.org/licenses/MIT MIT
 8:  */
 9: namespace Crunchmail\Resources;
10: 
11: /**
12:  * Domains entity class for Crunchmail API
13:  */
14: class DomainsResource extends GenericResource
15: {
16:     /**
17:      * Search domain name
18:      * You can pass an email or just the domain
19:      *
20:      * @param string $domain domain to search
21:      * @return array
22:      */
23:     public function search($email)
24:     {
25:         // for emails
26:         $pos = strpos($email, '@');
27: 
28:         // if @ is not found, it is already a domain
29:         $pos = $pos === false ? 0 : $pos + 1;
30: 
31:         // extract domain from email
32:         $domain = substr($email, $pos);
33: 
34:         // GET /domains/?name=$domain
35:         $this->filter(['name' => $domain]);
36:         return $this->get();
37:     }
38: 
39:     /**
40:      * Check if domains is validated (shortcut)
41:      *
42:      * @param string $domain domain to verify
43:      * @return boolean
44:      */
45:     public function verify($domain)
46:     {
47:         // get a collection of domains and retrieve the array
48:         $list = $this->search($domain)->current();
49:         return (count($list) > 0 && $list[0]->verify());
50:     }
51: }
52: 
API documentation generated by ApiGen