Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 17 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
ProcessUnRecognizedBounces | |
0.00% |
0 / 17 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
processUnRecognizedBounces | |
0.00% |
0 / 15 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\BounceHandler; |
4 | |
5 | use MailAddress; |
6 | use UserMailer; |
7 | |
8 | /** |
9 | * Class ProcessUnRecognizedBounces |
10 | * |
11 | * Process unrecognized bounce by notifying administrators |
12 | * |
13 | * @file |
14 | * @ingroup Extensions |
15 | * @author Tony Thomas, Kunal Mehta, Jeff Green |
16 | * @license GPL-2.0-or-later |
17 | */ |
18 | class ProcessUnRecognizedBounces { |
19 | /** |
20 | * @var string |
21 | */ |
22 | protected $passwordSender; |
23 | |
24 | /** |
25 | * @var array |
26 | */ |
27 | protected $unrecognizedBounceNotify; |
28 | |
29 | /** |
30 | * @param array $unrecognizedBounceNotify The array of admins to be notified |
31 | * on a bounce parse failure |
32 | * @param string $passwordSender The default email Return path address |
33 | */ |
34 | public function __construct( array $unrecognizedBounceNotify, $passwordSender ) { |
35 | $this->unrecognizedBounceNotify = $unrecognizedBounceNotify; |
36 | $this->passwordSender = $passwordSender; |
37 | } |
38 | |
39 | /** |
40 | * Notify the system administrator about a temporary bounce which failed to get parsed |
41 | * |
42 | * @param string $email The received email bounce |
43 | */ |
44 | public function processUnRecognizedBounces( $email ) { |
45 | if ( !$this->unrecognizedBounceNotify ) { |
46 | return; |
47 | } |
48 | $subject = 'bouncehandler-notify_subject'; |
49 | $sender = new MailAddress( $this->passwordSender, |
50 | wfMessage( 'emailsender' )->inContentLanguage()->text() ); |
51 | $to = []; |
52 | foreach ( $this->unrecognizedBounceNotify as $notifyEmails ) { |
53 | $to[] = new MailAddress( $notifyEmails ); |
54 | } |
55 | UserMailer::send( |
56 | $to, |
57 | $sender, |
58 | $subject, |
59 | $email, |
60 | [ 'replyTo' => $sender ] |
61 | ); |
62 | } |
63 | } |