Skip to content

Commit c9e8a34

Browse files
committed
create script for fetching disposable email providers
1 parent 67848ff commit c9e8a34

File tree

3 files changed

+5368
-4737
lines changed

3 files changed

+5368
-4737
lines changed

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,12 @@ class CustomEmailDataProvider implements EmailDataProviderInterface
177177

178178
### Is this validation accurate?
179179
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.
180+
181+
### Can I manually update the disposable email provider data?
182+
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
183+
184+
```shell
185+
./scripts/update-dispsable-email-providers.php
186+
```
187+
188+
from the command line. This will fetch the data and save it to *./src/data/disposable-email-providers.php*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env php
2+
3+
<?php
4+
5+
/*
6+
* To update disposable email providers from the command line run:
7+
* $ ./update-disposable-email-providers.php
8+
*/
9+
10+
$disposableEmailProvidersLocation = 'https://raw.githubusercontent.com/ivolo/disposable-email-domains/master/index.json';
11+
12+
$disposableEmailProvidersJson = file_get_contents($disposableEmailProvidersLocation);
13+
14+
if (!is_string($disposableEmailProvidersJson)) { die('Failed to fetch providers'); }
15+
16+
$disposableEmailProviders = json_decode($disposableEmailProvidersJson, true);
17+
18+
if (!is_array($disposableEmailProviders)) { die('Unable to decode JSON'); }
19+
20+
$exportedArray = var_export($disposableEmailProviders, true);
21+
22+
$phpFileTemplate = <<<TEMPLATE
23+
<?php
24+
25+
/**
26+
* This data is autogenerated.
27+
*
28+
* @see https://github.com/ivolo/disposable-email-domains
29+
*/
30+
31+
return {$exportedArray};
32+
33+
TEMPLATE;
34+
35+
$writeToFile = file_put_contents('../src/data/disposable-email-providers.php', $phpFileTemplate);
36+
37+
if (!$writeToFile) { die('Failed to write to file'); }
38+
39+
echo "Successfully Fetched Disposable Email Providers";
40+
exit();

0 commit comments

Comments
 (0)