-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMailer.php
More file actions
61 lines (53 loc) · 1.65 KB
/
Mailer.php
File metadata and controls
61 lines (53 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/**
* Arikaim
*
* @link http://www.arikaim.com
* @copyright Copyright (c) Konstantin Atanasov <info@arikaim.com>
* @license http://www.arikaim.com/license
* @package CoreAPI
*/
namespace Arikaim\Core\Api;
use Arikaim\Core\Controllers\ControlPanelApiController;
use Arikaim\Core\Utils\Utils;
/**
* Mailer controller
*/
class Mailer extends ControlPanelApiController
{
/**
* Init controller
*
* @return void
*/
public function init()
{
$this->loadMessages('system:admin.messages');
}
/**
* Send test email
*
* @param \Psr\Http\Message\ServerRequestInterface $request
* @param \Psr\Http\Message\ResponseInterface $response
* @param Validator $data
* @return Psr\Http\Message\ResponseInterface
*/
public function sendTestEmail($request, $response, $data)
{
$data->validate(true);
$user = $this->get('access')->getUser();
$componentName = $data->get('component','system:test');
if (Utils::isEmail($user['email']) == false) {
$this->setError('Control panel user email not valid!');
return;
}
$result = $this->get('mailer')->create($componentName)
->to($user['email'],'Admin User')
->send();
$this->setResponse($result,'mailer.send',function() {
$error = $this->get('mailer')->getErrorMessage();
$error = (empty($error) == true) ? 'errors.mailer.send' : $error;
$this->error($error);
});
}
}