PHP code example of danjam / gmail-matcher

1. Go to this page and download the library: Download danjam/gmail-matcher library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

danjam / gmail-matcher example snippets


// instantiate new matcher
$gmailMatcher = new \danjam\GmailMatcher\GmailMatcher();

// you can also specify the domain used when normalizing. Must be one of gmail.com, googlemail.com. Defaults to gmail.com
$gmailMatcher = new \danjam\GmailMatcher\GmailMatcher('googlemail.com');

// normalizes the address - returns [email protected]
$gmailMatcher->normalize('[email protected]');

// check if two addresses are the same - returns true
$gmailMatcher->match('[email protected]', '[email protected]');

// returns false
$gmailMatcher->match('[email protected]', '[email protected]');

// returns false - addresses with + should NOT be treated as the same address
$mailMatcher->match('foo@gmail', '[email protected]');

// multiple addresses
$gmailMatcher->match('[email protected]', '[email protected]', '[email protected]', ...);

// validate the address is a Gmail address - returns true
$gmailMatcher->isGmailAddress('[email protected]');

// returns false
$gmailMatcher->isGmailAddress('[email protected]');