This repository was archived by the owner on Mar 20, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +60
-0
lines changed Expand file tree Collapse file tree 4 files changed +60
-0
lines changed Original file line number Diff line number Diff line change 2
2
3
3
All notable changes to this package will be documented in this file.
4
4
5
+ ## v0.3.0
6
+
7
+ * add https://disposable-email-detector.com provider ` \Elbgoods\TrashmailRule\Providers\DisposableEmailDetectorProvider `
8
+
5
9
## v0.2.0
6
10
7
11
* switch to manager driver pattern
Original file line number Diff line number Diff line change 3
3
use GuzzleHttp \RequestOptions ;
4
4
5
5
return [
6
+ /*
7
+ * The list of providers that should run to decide whether an email is disposable or not.
8
+ * The order of providers is respected - so you should put the fastest or most important ones at the top.
9
+ */
6
10
'providers ' => [
7
11
'config ' ,
12
+ 'disposable_email_detector ' ,
8
13
'dead_letter ' ,
9
14
],
10
15
24
29
],
25
30
],
26
31
32
+ /*
33
+ * This package can do a request to https://www.disposable-email-detector.com
34
+ */
35
+ 'disposable_email_detector ' => [
36
+ 'enabled ' => true ,
37
+ 'guzzle ' => [
38
+ RequestOptions::TIMEOUT => 5 ,
39
+ ],
40
+ ],
41
+
27
42
/*
28
43
* Here you can define your own blacklisted domains.
29
44
*/
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Elbgoods \TrashmailRule \Providers ;
4
+
5
+ use Elbgoods \TrashmailRule \Contracts \ProviderContract ;
6
+
7
+ class DisposableEmailDetectorProvider implements ProviderContract
8
+ {
9
+ protected const BASE_URL = 'https://api.disposable-email-detector.com/api/dea/v1/check/ ' ;
10
+
11
+ protected array $ config ;
12
+
13
+ public function __construct (array $ config )
14
+ {
15
+ $ this ->config = $ config ;
16
+ }
17
+
18
+ public function isDisposable (string $ domain ): ?bool
19
+ {
20
+ if (! $ this ->config ['enabled ' ]) {
21
+ return null ;
22
+ }
23
+
24
+ $ response = guzzle (
25
+ self ::BASE_URL ,
26
+ $ this ->config ['guzzle ' ]
27
+ )->request ('GET ' , $ domain );
28
+
29
+ $ body = $ response ->getBody ()->getContents ();
30
+
31
+ return json_decode ($ body , true )['result ' ]['isDisposable ' ] ?? null ;
32
+ }
33
+ }
Original file line number Diff line number Diff line change 5
5
use Elbgoods \TrashmailRule \Contracts \ProviderContract ;
6
6
use Elbgoods \TrashmailRule \Providers \ConfigProvider ;
7
7
use Elbgoods \TrashmailRule \Providers \DeadLetterProvider ;
8
+ use Elbgoods \TrashmailRule \Providers \DisposableEmailDetectorProvider ;
8
9
use Illuminate \Support \Manager ;
9
10
use RuntimeException ;
10
11
@@ -48,4 +49,11 @@ protected function createDeadLetterDriver(): DeadLetterProvider
48
49
'config ' => $ this ->config ->get ('trashmail.dead_letter ' ),
49
50
]);
50
51
}
52
+
53
+ protected function createDisposableEmailDetectorDriver (): DisposableEmailDetectorProvider
54
+ {
55
+ return $ this ->container ->make (DisposableEmailDetectorProvider::class, [
56
+ 'config ' => $ this ->config ->get ('trashmail.disposable_email_detector ' ),
57
+ ]);
58
+ }
51
59
}
You can’t perform that action at this time.
0 commit comments