Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
allowedsender.php
1<?php
2
11
14
15Loc::loadMessages(__FILE__);
16
18{
24 public static function getList($forUserId = null)
25 {
26 $result = \Bitrix\Main\Mail\Sender::prepareUserMailboxes($forUserId);
27 if (!\Bitrix\Sender\Integration\Bitrix24\Service::isCloud())
28 {
29 $addressFromList = \Bitrix\Sender\MailingChainTable::getEmailFromList();
30
31 $address = new Address();
32 foreach ($addressFromList as $email)
33 {
34 $address->set($email);
35 $formatted = $address->get();
36 if (!$formatted)
37 {
38 continue;
39 }
40
41 $result[] = [
42 'name' => $address->getName(),
43 'email' => $address->getEmail(),
44 'formatted' => $address->get(),
45 ];
46 }
47 }
48 return $result;
49 }
50
57 public static function isAllowed($email, $userId = null)
58 {
59 if ($email == '')
60 {
61 return false;
62 }
63
64 $address = new Address();
65 $address->set($email);
66 $normalizedEmail = $address->getEmail();
67 if (!$normalizedEmail)
68 {
69 return false;
70 }
71 $normalizedEmail = mb_strtolower($normalizedEmail);
72 $allowedSenders = self::getList($userId);
73 if (empty(array_filter($allowedSenders, function ($item) use ($normalizedEmail)
74 {
75 return mb_strtolower($item['email']) === $normalizedEmail;
76 })))
77 {
78 return false;
79 }
80
81 return true;
82 }
83}
static loadMessages($file)
Definition loc.php:64