3namespace Bitrix\Main\Controller\Mail;
5use Bitrix\Main\Engine\Controller;
6use Bitrix\Main\Engine\CurrentUser;
7use Bitrix\Main\Localization\Loc;
23 $smtp = $sender[
'OPTIONS'][
'smtp'] ?? [];
28 'server' => $smtp[
'server'] ??
null,
29 'port' => $smtp[
'port'] ??
null,
30 'protocol' => $smtp[
'protocol'] ??
null,
31 'login' => $smtp[
'login'] ??
null,
32 'limit' => $smtp[
'limit'] ??
null,
39 'email' => $sender[
'EMAIL'],
41 'isPublic' => (
int)$sender[
'IS_PUBLIC'] === 1,
48 return Main\Mail\Sender::prepareUserMailboxes();
70 $userId = (int)CurrentUser::get()->getId();
72 $email = mb_strtolower(trim((
string)(
$data[
'email'] ??
'')));
75 $errorCode = empty(
$email) ?
'MAIN_CONTROLLER_MAIL_SENDER_EMPTY_EMAIL' :
'MAIN_CONTROLLER_MAIL_SENDER_INVALID_EMAIL';
76 $this->
addError(
new Error(Loc::getMessage($errorCode),
'ERR_INVALID_EMAIL'));
81 $senderId = (int)(
$data[
'id'] ??
null);
82 if (!$senderId &&
Mail\Sender::hasUserSenderWithEmail(
$email))
84 $this->
addError(
new Error(Loc::getMessage(
'MAIN_CONTROLLER_MAIL_SENDER_EXISTS_SENDER'),
'ERR_EXISTS_SENDER'));
89 $smtp =
$data[
'smtp'] ?? [];
93 $checkResult = Main\Mail\Sender::canEditSender($senderId);
94 if (!$checkResult->isSuccess())
96 $this->
addErrors($checkResult->getErrors());
102 $userId = (int)$sender[
'USER_ID'];
103 if (!empty($smtp) && empty($smtp[
'password']) && $sender[
'OPTIONS'][
'smtp'])
105 $smtp[
'password'] = $sender[
'OPTIONS'][
'smtp'][
'password'];
111 if (!is_array($smtp))
113 $this->
addError(
new Error(Loc::getMessage(
'MAIN_CONTROLLER_MAIL_SENDER_AJAX_ERROR'),
'ERR_EMAIL'));
118 $result = Mail\Sender::prepareSmtpConfigForSender($smtp);
133 'IS_CONFIRMED' =>
true,
140 $fields[
'OPTIONS'][
'smtp'] = $smtp;
161 $senderId =
$result[
'senderId'] ??
null;
167 if(!$updateResult->isSuccess())
169 $this->
addError($updateResult->getErrors()[0]);
175 if ($smtp && $smtp[
'limit'] !==
null)
177 Main\Mail\Sender::setEmailLimit(
$email, $smtp[
'limit']);
179 elseif ($smtp && !isset($smtp[
'limit']))
181 Main\Mail\Sender::removeEmailLimit(
$email);
185 'senderId' => $senderId ??
null,
195 $userId = (int)CurrentUser::get()->getId();
210 'IS_CONFIRMED' =>
true,
222 $result[
'avatar'] = $userData[
'userAvatar'] ??
null;
223 $result[
'userUrl'] = $userData[
'userUrl'] ??
null;
230 $checkResult = Main\Mail\Sender::canEditSender($senderId);
231 if (!$checkResult->isSuccess())
233 $this->
addErrors($checkResult->getErrors());
243 $result = Main\Mail\Sender::updateSender($senderId, [
'NAME' =>
$name]);
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
deleteSenderAction(int $senderId)
addAliasAction(string $name, string $email)
getSenderByMailboxIdAction(int $mailboxId, bool $getSenderWithoutSmtp=false)
getSenderTransitionalDataAction(int $senderId)
getSenderDataAction(int $senderId)
getDefaultSenderNameAction()
getAvailableSendersAction()
submitSenderAction(array $data)
updateSenderNameAction(int $senderId, string $name)
static getSenderNameByMailboxId(int $mailboxId, bool $getSenderWithoutSmtp=false)
static getSenderTransitionalData(int $senderId)
static getUserFormattedName(?int $userId=null)
static getUserInfo(int $userId)
static update($primary, array $data)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
check_email($email, $strict=false, $domainCheck=false)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)