1
|
|
|
<?php |
2
|
|
|
/* vim: set expandtab sw=4 ts=4 sts=4: */ |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* Mailer component handling sending of report notification mails |
6
|
|
|
* |
7
|
|
|
* phpMyAdmin Error reporting server |
8
|
|
|
* Copyright (c) phpMyAdmin project (https://www.phpmyadmin.net/) |
9
|
|
|
* |
10
|
|
|
* Licensed under The MIT License |
11
|
|
|
* For full copyright and license information, please see the LICENSE.txt |
12
|
|
|
* Redistributions of files must retain the above copyright notice. |
13
|
|
|
* |
14
|
|
|
* @copyright Copyright (c) phpMyAdmin project (https://www.phpmyadmin.net/) |
15
|
|
|
* @license https://opensource.org/licenses/mit-license.php MIT License |
16
|
|
|
* |
17
|
|
|
* @see https://www.phpmyadmin.net/ |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
namespace App\Controller\Component; |
21
|
|
|
|
22
|
|
|
use Cake\Controller\Component; |
23
|
|
|
use Cake\ORM\TableRegistry; |
24
|
|
|
use Cake\Mailer\Email; |
25
|
|
|
use Cake\Core\Configure; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Mailer component handling report notification emails. |
29
|
|
|
*/ |
30
|
|
|
class MailerComponent extends Component |
31
|
|
|
{ |
32
|
|
|
/** |
33
|
|
|
* Send an email about the report to configured Email |
34
|
|
|
* |
35
|
|
|
* @param $viewVars Array of View Variables |
36
|
|
|
* |
37
|
|
|
* @return boolean if Email was sent |
38
|
|
|
*/ |
39
|
1 |
|
public function sendReportMail($viewVars) |
40
|
|
|
{ |
41
|
1 |
|
$email = new Email('default'); |
42
|
1 |
|
$emailTo = Configure::read('NotificationEmailsTo'); |
43
|
1 |
|
$emailFrom = Configure::read('NotificationEmailsFrom'); |
44
|
1 |
|
$emailTransport = Configure::read('NotificationEmailsTransport'); |
45
|
|
|
|
46
|
1 |
|
if (! $emailTo || $emailTo === '' |
47
|
1 |
|
|| ! $emailFrom || $emailFrom === '' |
48
|
|
|
) { |
49
|
|
|
return false; |
50
|
|
|
} |
51
|
|
|
|
52
|
1 |
|
$email->setTransport($emailTransport) |
|
|
|
|
53
|
1 |
|
->viewVars($viewVars) |
54
|
1 |
|
->subject( |
55
|
1 |
|
sprintf( |
56
|
1 |
|
'A new report has been submitted on the Error Reporting Server: %s', |
57
|
1 |
|
$viewVars['report']['id'] |
58
|
|
|
) |
59
|
|
|
) |
60
|
1 |
|
->template('report', 'default') |
61
|
1 |
|
->emailFormat('html') |
62
|
1 |
|
->to($emailTo) |
63
|
1 |
|
->from($emailFrom) |
64
|
1 |
|
->send(); |
65
|
|
|
|
66
|
1 |
|
return true; |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.