Skip to content

Commit

Permalink
create script for fetching disposable email providers
Browse files Browse the repository at this point in the history
  • Loading branch information
daveearley committed Apr 13, 2018
1 parent 67848ff commit c9e8a34
Show file tree
Hide file tree
Showing 3 changed files with 5,368 additions and 4,737 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,12 @@ class CustomEmailDataProvider implements EmailDataProviderInterface

### Is this validation accurate?
No, none of these tests are 100% accurate. As with any email validation there will always be false positives & negatives. The only way to guarantee an email is valid is to send an email and solicit a response. However, this library is still useful for detecting disposable emails etc., and also acts as a good first line of defence.

### Can I manually update the disposable email provider data?
Yes, this project relies on [this great]( https://github.com/ivolo/disposable-email-domains) repository for its list of disposable email providers. To fetch the latest list from that repo you can run

```shell
./scripts/update-dispsable-email-providers.php
```

from the command line. This will fetch the data and save it to *./src/data/disposable-email-providers.php*
40 changes: 40 additions & 0 deletions scripts/update-disposable-email-providers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env php

<?php

/*
* To update disposable email providers from the command line run:
* $ ./update-disposable-email-providers.php
*/

$disposableEmailProvidersLocation = 'https://raw.githubusercontent.com/ivolo/disposable-email-domains/master/index.json';

$disposableEmailProvidersJson = file_get_contents($disposableEmailProvidersLocation);

if (!is_string($disposableEmailProvidersJson)) { die('Failed to fetch providers'); }

$disposableEmailProviders = json_decode($disposableEmailProvidersJson, true);

if (!is_array($disposableEmailProviders)) { die('Unable to decode JSON'); }

$exportedArray = var_export($disposableEmailProviders, true);

$phpFileTemplate = <<<TEMPLATE
<?php
/**
* This data is autogenerated.
*
* @see https://github.com/ivolo/disposable-email-domains
*/
return {$exportedArray};
TEMPLATE;

$writeToFile = file_put_contents('../src/data/disposable-email-providers.php', $phpFileTemplate);

if (!$writeToFile) { die('Failed to write to file'); }

echo "Successfully Fetched Disposable Email Providers";
exit();
Loading

0 comments on commit c9e8a34

Please sign in to comment.