1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Teampass - a collaborative passwords manager. |
4
|
|
|
* --- |
5
|
|
|
* This file is part of the TeamPass project. |
6
|
|
|
* |
7
|
|
|
* TeamPass is free software: you can redistribute it and/or modify it |
8
|
|
|
* under the terms of the GNU General Public License as published by |
9
|
|
|
* the Free Software Foundation, version 3 of the License. |
10
|
|
|
* |
11
|
|
|
* TeamPass is distributed in the hope that it will be useful, |
12
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14
|
|
|
* GNU General Public License for more details. |
15
|
|
|
* |
16
|
|
|
* You should have received a copy of the GNU General Public License |
17
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
18
|
|
|
* |
19
|
|
|
* Certain components of this file may be under different licenses. For |
20
|
|
|
* details, see the `licenses` directory or individual file headers. |
21
|
|
|
* --- |
22
|
|
|
* @file EmailTrait.php |
23
|
|
|
* @author Nils Laumaillé ([email protected]) |
24
|
|
|
* @copyright 2009-2025 Teampass.net |
25
|
|
|
* @license GPL-3.0 |
26
|
|
|
* @see https://www.teampass.net |
27
|
|
|
*/ |
28
|
|
|
|
29
|
|
|
use TeampassClasses\EmailService\EmailService; |
30
|
|
|
use TeampassClasses\EmailService\EmailSettings; |
31
|
|
|
|
32
|
|
|
trait EmailTrait { |
33
|
|
|
/** |
34
|
|
|
* Envoie un email |
35
|
|
|
* @param array $arguments Arguments nécessaires pour l'envoi d'email |
36
|
|
|
*/ |
37
|
|
|
private function sendEmail($arguments) { |
38
|
|
|
// Prepare email properties |
39
|
|
|
$emailSettings = new EmailSettings($this->settings); |
40
|
|
|
$emailService = new EmailService(); |
41
|
|
|
|
42
|
|
|
// if email.encryptedUserPassword is set, decrypt it |
43
|
|
|
if (isset($arguments['encryptedUserPassword']) === true) { |
44
|
|
|
$userPassword = cryption($arguments['encryptedUserPassword'], '', 'decrypt', $this->settings)['string']; |
45
|
|
|
$arguments['body'] = str_replace('#password#', $userPassword, $arguments['body']); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
// send email |
49
|
|
|
$emailService->sendMail( |
50
|
|
|
$arguments['subject'], |
51
|
|
|
$arguments['body'], |
52
|
|
|
$arguments['receivers'], |
53
|
|
|
$emailSettings, |
54
|
|
|
null, |
55
|
|
|
true, |
56
|
|
|
true |
57
|
|
|
); |
58
|
|
|
} |
59
|
|
|
} |