19 declare(strict_types=1);
59 private int $a_user_id,
70 private ?
Closure $usr_id_by_login_callable = null,
72 private ?
int $mail_admin_node_ref_id = null,
73 private ?
int $mail_obj_ref_id = null,
83 $this->event_handler = $event_handler ?? $DIC->event();
84 $this->db = $db ?? $DIC->database();
85 $this->
lng =
$lng ?? $DIC->language();
86 $this->actor = $actor ?? $DIC->user();
87 $this->mail_file_data = $mail_file_data ??
new ilFileDataMail($a_user_id);
88 $this->mail_options = $mail_options ??
new ilMailOptions($a_user_id);
89 $this->mailbox = $mailbox ??
new ilMailbox($a_user_id);
91 $this->sender_factory = $sender_factory ?? $DIC->mail()->mime()->senderFactory();
92 $this->usr_id_by_login_callable = $usr_id_by_login_callable ??
static function (
string $login):
int {
95 $this->auto_responder_service = $auto_responder_service ?? $DIC->mail()->autoresponder();
96 $this->user_id = $a_user_id;
97 if (null === $this->mail_obj_ref_id) {
100 $this->
lng->loadLanguageModule(
'mail');
101 $this->table_mail =
'mail';
102 $this->table_mail_saved =
'mail_saved';
104 $this->placeholder_resolver = $placeholder_resolver ?? $DIC->mail()->placeholderResolver();
105 $this->placeholder_to_empty_resolver = $placeholder_to_empty_resolver ?? $DIC->mail()->placeholderToEmptyResolver();
106 $this->legal_documents = $legal_documents ?? $DIC[
'legalDocuments'];
107 $this->signature_service = $signature_service ?? $DIC->mail()->signature();
112 return $this->auto_responder_service;
117 $clone = clone $this;
119 $clone->context_id = $contextId;
126 $clone = clone $this;
128 $clone->context_parameters = $parameters;
138 public function existsRecipient(
string $newRecipient,
string $existingRecipients): bool
145 $diffedAddresses = $list->value();
147 return $diffedAddresses === [];
152 $this->save_in_sentbox = $saveInSentbox;
167 return $this->mail_obj_ref_id;
172 $recipients = trim($recipients);
173 if ($recipients ===
'') {
174 return $this->
lng->txt(
'not_available');
179 $recipients = array_filter(
array_map(
'trim', explode(
',', $recipients)));
180 foreach ($recipients as $recipient) {
182 if (is_int($usrId) && $usrId > 0) {
184 if ($pp ===
'g' || ($pp ===
'y' && !$this->actor->isAnonymous())) {
187 $names[] = $user->getFullname() .
' [' . $recipient .
']';
193 $names[] = $recipient;
196 return implode(
', ', $names);
201 $this->db->setLimit(1, 0);
203 $query = implode(
' ', [
204 "SELECT b.* FROM $this->table_mail a",
205 "INNER JOIN $this->table_mail b ON b.folder_id = a.folder_id",
206 'AND b.user_id = a.user_id AND b.send_time > a.send_time',
207 'WHERE a.user_id = %s AND a.mail_id = %s ORDER BY b.send_time ASC',
209 $res = $this->db->queryF(
211 [
'integer',
'integer'],
212 [$this->user_id, $mailId]
222 $this->db->setLimit(1, 0);
224 $query = implode(
' ', [
225 "SELECT b.* FROM $this->table_mail a",
226 "INNER JOIN $this->table_mail b ON b.folder_id = a.folder_id",
227 'AND b.user_id = a.user_id AND b.send_time < a.send_time',
228 'WHERE a.user_id = %s AND a.mail_id = %s ORDER BY b.send_time DESC',
230 $res = $this->db->queryF(
232 [
'integer',
'integer'],
233 [$this->user_id, $mailId]
246 "SELECT sender_id, m_subject, mail_id, m_status, send_time, import_name " .
247 "FROM $this->table_mail " .
248 "LEFT JOIN object_data ON obj_id = sender_id " .
249 "WHERE user_id = %s AND folder_id = %s " .
250 "AND ((sender_id > 0 AND sender_id IS NOT NULL AND obj_id IS NOT NULL) " .
251 "OR (sender_id = 0 OR sender_id IS NULL))";
253 if (isset($filter[
'status']) && $filter[
'status'] !==
'') {
254 $query .=
' AND m_status = ' . $this->db->quote($filter[
'status'],
'text');
257 $query .=
" ORDER BY send_time DESC";
259 $res = $this->db->queryF(
261 [
'integer',
'integer'],
262 [$this->user_id, $a_folder_id]
265 while ($row = $this->db->fetchAssoc(
$res)) {
269 return array_filter($mails);
274 $res = $this->db->queryF(
275 "SELECT COUNT(*) FROM $this->table_mail WHERE user_id = %s AND folder_id = %s",
276 [
'integer',
'integer'],
277 [$this->user_id, $folderId]
280 return $this->db->numRows(
$res);
286 foreach ($mails as $mail_data) {
293 $res = $this->db->queryF(
294 "SELECT * FROM $this->table_mail WHERE user_id = %s AND mail_id = %s",
295 [
'integer',
'integer'],
296 [$this->user_id, $mailId]
312 $query =
"UPDATE $this->table_mail SET m_status = %s WHERE user_id = %s ";
314 $types[] =
'integer';
318 if ($mailIds !== []) {
319 $query .=
' AND ' . $this->db->in(
'mail_id', $mailIds,
false,
'integer');
322 $this->db->manipulateF($query, $types, $values);
333 $query =
"UPDATE $this->table_mail SET m_status = %s WHERE user_id = %s ";
335 $types[] =
'integer';
336 $values[] =
'unread';
339 if ($mailIds !== []) {
340 $query .=
' AND ' . $this->db->in(
'mail_id', $mailIds,
false,
'integer');
343 $this->db->manipulateF($query, $types, $values);
354 $mailIds = array_filter(
array_map(
'intval', $mailIds));
356 if ([] === $mailIds) {
361 "UPDATE $this->table_mail " .
362 "INNER JOIN mail_obj_data " .
363 "ON mail_obj_data.obj_id = %s AND mail_obj_data.user_id = %s " .
364 "SET $this->table_mail.folder_id = mail_obj_data.obj_id " .
365 "WHERE $this->table_mail.user_id = %s";
366 $types[] =
'integer';
367 $types[] =
'integer';
368 $types[] =
'integer';
369 $values[] = $folderId;
373 $query .=
' AND ' . $this->db->in(
'mail_id', $mailIds,
false,
'integer');
375 $affectedRows = $this->db->manipulateF($query, $types, $values);
377 return $affectedRows > 0;
385 $mailIds = array_filter(
array_map(
'intval', $mailIds));
386 foreach ($mailIds as
$id) {
387 $this->db->manipulateF(
388 "DELETE FROM $this->table_mail WHERE user_id = %s AND mail_id = %s",
389 [
'integer',
'integer'],
390 [$this->user_id, $id]
392 $this->mail_file_data->deassignAttachmentFromDirectory($id);
398 if (!is_array($row) || empty($row)) {
402 if (isset($row[
'attachments'])) {
403 $unserialized = unserialize(stripslashes($row[
'attachments']), [
'allowed_classes' =>
false]);
404 $row[
'attachments'] = is_array($unserialized) ? $unserialized : [];
406 $row[
'attachments'] = [];
409 if (isset($row[
'tpl_ctx_params']) && is_string($row[
'tpl_ctx_params'])) {
410 $decoded = json_decode($row[
'tpl_ctx_params'],
true, 512, JSON_THROW_ON_ERROR);
411 $row[
'tpl_ctx_params'] = (array) ($decoded ?? []);
413 $row[
'tpl_ctx_params'] = [];
416 if (isset($row[
'mail_id'])) {
417 $row[
'mail_id'] = (
int) $row[
'mail_id'];
420 if (isset($row[
'user_id'])) {
421 $row[
'user_id'] = (
int) $row[
'user_id'];
424 if (isset($row[
'folder_id'])) {
425 $row[
'folder_id'] = (
int) $row[
'folder_id'];
428 if (isset($row[
'sender_id'])) {
429 $row[
'sender_id'] = (
int) $row[
'sender_id'];
432 if (isset($row[
'use_placeholders'])) {
433 $row[
'use_placeholders'] = (bool) $row[
'use_placeholders'];
436 $null_to_string_properties = [
'm_subject',
'm_message',
'rcp_to',
'rcp_cc',
'rcp_bcc'];
437 foreach ($null_to_string_properties as $null_to_string_property) {
438 if (!isset($row[$null_to_string_property])) {
439 $row[$null_to_string_property] =
'';
448 $nextId = $this->db->nextId($this->table_mail);
449 $this->db->insert($this->table_mail, [
450 'mail_id' => [
'integer', $nextId],
451 'user_id' => [
'integer', $this->user_id],
452 'folder_id' => [
'integer', $folderId],
453 'sender_id' => [
'integer', $this->user_id],
464 array $a_attachments,
471 bool $a_use_placeholders =
false,
472 ?
string $a_tpl_context_id = null,
473 array $a_tpl_context_params = []
478 'folder_id' => [
'integer', $a_folder_id],
479 'attachments' => [
'clob', serialize($a_attachments)],
480 'send_time' => [
'timestamp', date(
'Y-m-d H:i:s')],
481 'rcp_to' => [
'clob', $a_rcp_to],
482 'rcp_cc' => [
'clob', $a_rcp_cc],
483 'rcp_bcc' => [
'clob', $a_rcp_bcc],
484 'm_status' => [
'text',
'read'],
485 'm_subject' => [
'text', $a_m_subject],
486 'm_message' => [
'clob', $a_m_message],
487 'use_placeholders' => [
'integer', (
int) $a_use_placeholders],
488 'tpl_ctx_id' => [
'text', $a_tpl_context_id],
489 'tpl_ctx_params' => [
'blob', json_encode($a_tpl_context_params, JSON_THROW_ON_ERROR)],
492 'mail_id' => [
'integer', $a_draft_id],
510 bool $usePlaceholders =
false,
511 ?
string $templateContextId = null,
512 array $templateContextParameters = []
516 if ($usePlaceholders) {
519 $message = str_ireplace([
"<br />",
"<br>",
"<br/>"],
"\n", $message);
521 $nextId = $this->db->nextId($this->table_mail);
522 $this->db->insert($this->table_mail, [
523 'mail_id' => [
'integer', $nextId],
524 'user_id' => [
'integer', $usrId],
525 'folder_id' => [
'integer', $folderId],
526 'sender_id' => [
'integer', $senderUsrId],
527 'attachments' => [
'clob', serialize($attachments)],
528 'send_time' => [
'timestamp', date(
'Y-m-d H:i:s')],
529 'rcp_to' => [
'clob', $to],
530 'rcp_cc' => [
'clob', $cc],
531 'rcp_bcc' => [
'clob', $bcc],
532 'm_status' => [
'text', $status],
533 'm_subject' => [
'text', $subject],
534 'm_message' => [
'clob', $message],
535 'tpl_ctx_id' => [
'text', $templateContextId],
536 'tpl_ctx_params' => [
'blob', json_encode($templateContextParameters, JSON_THROW_ON_ERROR)],
539 $sender_equals_reveiver = $usrId === $this->mailbox->getUsrId();
540 $is_sent_folder_of_sender =
false;
541 if ($sender_equals_reveiver) {
543 $is_sent_folder_of_sender = $folderId === $current_folder_id;
546 $raise_event = !$sender_equals_reveiver || !$is_sent_folder_of_sender;
549 $this->event_handler->raise(
'components/ILIAS/Mail',
'sentInternalMail', [
551 'subject' => $subject,
553 'from_usr_id' => $senderUsrId,
554 'to_usr_id' => $usrId,
569 if ($this->context_id) {
576 $message = $this->placeholder_resolver->resolve(
580 $this->context_parameters
583 $this->
logger->error(sprintf(
584 '%s has been called with invalid context: %s / %s',
587 $e->getTraceAsString()
596 return $this->placeholder_to_empty_resolver->resolve($message);
601 $this->auto_responder_service->emptyAutoresponderData();
603 $this->
logger->debug(sprintf(
604 "Parsed TO user ids from given recipients for serial letter notification: %s",
605 implode(
', ', $to_usr_ids)
613 $this->
logger->debug(sprintf(
614 "Parsed CC/BCC user ids from given recipients for serial letter notification: %s",
615 implode(
', ', $other_usr_ids)
625 $this->auto_responder_service->disableAutoresponder();
626 $this->auto_responder_service->handleAutoresponderMails($this->user_id);
635 foreach ($to_usr_ids as $user_id) {
660 array $cc_bcc_recipients
669 array_merge($to_recipients, $cc_bcc_recipients),
683 $usrIdToExternalEmailAddressesMap = [];
685 foreach ($recipients as $recipient) {
686 if (!$recipient->isUser()) {
687 $this->
logger->critical(sprintf(
688 "Skipped recipient with id %s (User not found)",
689 $recipient->getUserId()
694 $can_read_internal = $recipient->evaluateInternalMailReadability();
695 if ($this->
isSystemMail() && !$can_read_internal->isOk()) {
696 $this->
logger->debug(sprintf(
697 'Skipped recipient with id %s and reason: %s',
698 $recipient->getUserId(),
699 is_string($can_read_internal->error()) ? $can_read_internal->error() : $can_read_internal->error()->getMessage()
704 if ($recipient->isUserActive()) {
705 if (!$can_read_internal->isOk() || $recipient->userWantsToReceiveExternalMails()) {
706 $emailAddresses = $recipient->getExternalMailAddress();
707 $usrIdToExternalEmailAddressesMap[$recipient->getUserId()] = $emailAddresses;
709 if ($recipient->onlyToExternalMailAddress()) {
710 $this->
logger->debug(sprintf(
711 "Recipient with id %s will only receive external emails sent to: %s",
712 $recipient->getUserId(),
713 implode(
', ', $emailAddresses)
718 $this->
logger->debug(sprintf(
719 "Recipient with id %s will additionally receive external emails " .
720 "(because the user wants to receive it externally, or the user cannot access " .
721 "the internal mail system) sent to: %s",
722 $recipient->getUserId(),
723 implode(
', ', $emailAddresses)
726 $this->
logger->debug(sprintf(
727 "Recipient with id %s is does not want to receive external emails",
728 $recipient->getUserId()
732 $this->
logger->debug(sprintf(
733 "Recipient with id %s is inactive and will not receive external emails",
734 $recipient->getUserId()
738 $mbox = clone $this->mailbox;
739 $mbox->setUsrId($recipient->getUserId());
740 $recipientInboxId = $mbox->getInboxFolder();
752 $recipient->getUserId()
755 $this->auto_responder_service->enqueueAutoresponderIfEnabled(
756 $recipient->getUserId(),
757 $recipient->getMailOptions(),
762 $this->mail_file_data->assignAttachmentsToDirectory($internalMailId, $mail_data->
getInternalMailId());
770 $usrIdToExternalEmailAddressesMap
782 array $usrIdToExternalEmailAddressesMap
784 if (1 === count($usrIdToExternalEmailAddressesMap)) {
785 $usrIdToExternalEmailAddressesMap = array_values($usrIdToExternalEmailAddressesMap);
786 $firstAddresses = current($usrIdToExternalEmailAddressesMap);
789 implode(
',', $firstAddresses),
796 } elseif (count($usrIdToExternalEmailAddressesMap) > 1) {
798 $usrIdToExternalEmailAddressesMap
801 $flattenEmailAddresses = array_unique($flattenEmailAddresses);
804 $remainingAddresses =
'';
805 foreach ($flattenEmailAddresses as $emailAddress) {
807 if ($remainingAddresses !==
'') {
813 if ($recipientsLineLength >= $this->max_recipient_character_length) {
823 $remainingAddresses =
'';
827 $remainingAddresses .= ($sep . $emailAddress);
830 if (
'' !== $remainingAddresses) {
849 $parsed_usr_ids = [];
851 $joined_recipients = implode(
',', array_filter(
array_map(
'trim', $recipients)));
854 foreach ($addresses as $address) {
855 $address_type = $this->mail_address_type_factory->getByPrefix($address);
856 $parsed_usr_ids[] = $address_type->resolve();
859 return array_unique(array_merge(...$parsed_usr_ids));
865 private function checkMail(
string $to,
string $cc,
string $bcc,
string $subject): array
870 $subject =>
'mail_add_subject',
871 $to =>
'mail_add_recipient',
873 foreach ($checks as $string => $error) {
874 if ($string ===
'') {
881 $errors[] =
new ilMailError(
'mail_subject_too_long');
897 foreach ($addresses as $address) {
898 $address_type = $this->mail_address_type_factory->getByPrefix($address);
899 if (!$address_type->validate($this->user_id)) {
900 $errors[] = $address_type->getErrors();
904 $colonPosition = strpos($e->getMessage(),
':');
906 ($colonPosition ===
false) ? $e->getMessage() : substr($e->getMessage(), $colonPosition + 2),
912 return array_merge(...$errors);
920 array $a_attachments,
926 bool $a_use_placeholders =
false,
927 ?
string $a_tpl_context_id = null,
928 ?array $a_tpl_ctx_params = []
931 $this->table_mail_saved,
933 'user_id' => [
'integer', $this->user_id],
936 'attachments' => [
'clob', serialize($a_attachments)],
937 'rcp_to' => [
'clob', $a_rcp_to],
938 'rcp_cc' => [
'clob', $a_rcp_cc],
939 'rcp_bcc' => [
'clob', $a_rcp_bcc],
940 'm_subject' => [
'text', $a_m_subject],
941 'm_message' => [
'clob', $a_m_message],
942 'use_placeholders' => [
'integer', (
int) $a_use_placeholders],
943 'tpl_ctx_id' => [
'text', $a_tpl_context_id],
944 'tpl_ctx_params' => [
'blob', json_encode((array) $a_tpl_ctx_params, JSON_THROW_ON_ERROR)],
955 $res = $this->db->queryF(
956 "SELECT * FROM $this->table_mail_saved WHERE user_id = %s",
962 if (!is_array($this->mail_data)) {
963 $this->
persistToStage($this->user_id, [],
'',
'',
'',
'',
'',
false);
981 bool $a_use_placeholders =
false 986 $a_m_subject = $sanitizeMb4Encoding->transform($a_m_subject);
987 $a_m_message = $sanitizeMb4Encoding->transform($a_m_message);
990 "New mail system task:" .
991 " To: " . $a_rcp_to .
992 " | CC: " . $a_rcp_cc .
993 " | BCC: " . $a_rcp_bcc .
994 " | Subject: " . $a_m_subject .
995 " | Attachments: " . print_r($a_attachment,
true)
998 if ($a_attachment && !$this->mail_file_data->checkFilesExist($a_attachment)) {
999 return [
new ilMailError(
'mail_attachment_file_not_exist', [$a_attachment])];
1002 $errors = $this->
checkMail($a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_m_subject);
1003 if ($errors !== []) {
1008 if ($errors !== []) {
1012 $rcp_to = $a_rcp_to;
1013 $rcp_cc = $a_rcp_cc;
1014 $rcp_bcc = $a_rcp_bcc;
1018 $numberOfExternalAddresses > 0 &&
1020 !$DIC->rbac()->system()->checkAccessOfUser($this->user_id,
'smtp_mail', $this->mail_obj_ref_id)
1022 return [
new ilMailError(
'mail_no_permissions_write_smtp')];
1026 $a_m_message .= self::_getInstallationSignature();
1039 return $this->
sendMail($mail_data);
1042 $taskFactory = $DIC->backgroundTasks()->taskFactory();
1043 $taskManager = $DIC->backgroundTasks()->taskManager();
1046 $bucket->setUserId($this->user_id);
1048 $task = $taskFactory->createTask(ilMailDeliveryJob::class, [
1055 serialize($a_attachment),
1056 $a_use_placeholders,
1058 (
string) $this->context_id,
1059 serialize(array_merge(
1060 $this->context_parameters,
1062 'auto_responder' => $this->auto_responder_service->isAutoresponderEnabled()
1066 $interaction = $taskFactory->createTask(ilMailDeliveryJobUserInteraction::class, [
1071 $bucket->setTask($interaction);
1072 $bucket->setTitle($this->
lng->txt(
'mail_bg_task_title'));
1073 $bucket->setDescription(sprintf($this->
lng->txt(
'mail_bg_task_desc'), $a_m_subject));
1075 $this->
logger->info(
'Delegated delivery to background task');
1076 $taskManager->run($bucket);
1094 $mail_data->
getTo(),
1095 $mail_data->
getCc(),
1102 if ($mail_data->getAttachments() !== []) {
1103 $this->mail_file_data->assignAttachmentsToDirectory($internalMessageId, $internalMessageId);
1104 $this->mail_file_data->saveFiles($internalMessageId, $mail_data->getAttachments());
1107 $numberOfExternalAddresses = $this->
getCountRecipients($mail_data->getTo(), $mail_data->getCc(), $mail_data->getBcc());
1109 if ($numberOfExternalAddresses > 0) {
1115 "Parsed external email addresses from given recipients /" .
1116 " To: " . $externalMailRecipientsTo .
1117 " | CC: " . $externalMailRecipientsCc .
1118 " | BCC: " . $externalMailRecipientsBcc .
1119 " | Subject: " . $mail_data->getSubject()
1123 $externalMailRecipientsTo,
1124 $externalMailRecipientsCc,
1125 $externalMailRecipientsBcc,
1126 $mail_data->getSubject(),
1127 $mail_data->isUsePlaceholder() ?
1129 $mail_data->getMessage(),
1130 $mail_data->getAttachments()
1133 $this->
logger->debug(
'No external email addresses given in recipient string');
1139 $errors[
'mail_send_error'] =
new ilMailError(
'mail_send_error');
1147 $random =
new Random\Randomizer();
1148 if ($random->getInt(0, 50) === 2) {
1151 $this->mail_file_data
1156 return array_values($errors);
1170 if ($errors !== []) {
1171 return array_merge([
new ilMailError(
'mail_following_rcp_not_valid')], $errors);
1174 return [
new ilMailError(
'mail_generic_rcp_error', [$e->getMessage()])];
1182 $send_folder_id = 0;
1184 $send_folder_id = $this->mailbox->getSentFolder();
1187 return $send_folder_id;
1227 $mailer->From($this->sender_factory->getSenderByUsrId($this->user_id));
1232 (
string) ($this->context_parameters[self::PROP_CONTEXT_SUBJECT_PREFIX] ??
'')
1236 $message .= $this->signature_service->user($this->user_id);
1238 $mailer->Body($message);
1249 foreach ($attachments as $attachment) {
1251 $this->mail_file_data->getAbsoluteAttachmentPoolPathByFilename($attachment),
1267 $this->table_mail_saved,
1269 'attachments' => [
'clob', serialize($attachments)],
1272 'user_id' => [
'integer', $this->user_id],
1283 if ($addresses !==
'') {
1284 $this->
logger->debug(sprintf(
1285 "Started parsing of recipient string: %s",
1290 $parser = $this->mail_address_parser_factory->getParser($addresses);
1291 $parsedAddresses = $parser->parse();
1293 if ($addresses !==
'') {
1294 $this->
logger->debug(sprintf(
1295 "Parsed addresses: %s",
1297 return (
string) $address;
1298 }, $parsedAddresses))
1302 return $parsedAddresses;
1308 if ($onlyExternalAddresses) {
1312 $this->usr_id_by_login_callable
1316 return count($addresses->value());
1320 string $toRecipients,
1321 string $ccRecipients,
1322 string $bccRecipients,
1323 bool $onlyExternalAddresses =
true 1337 $this->usr_id_by_login_callable
1341 return (
string) $address;
1342 }, $addresses->value());
1344 return implode(
',', $emailRecipients);
1355 $lang->loadLanguageModule(
'mail');
1358 $lang->txt(
'mail_auto_generated_info'),
1367 $senderFactory = $DIC->mail()->mime()->senderFactory();
1369 return $senderFactory->system()->getFromName();
1378 if (null === $a_flag) {
1382 $this->append_installation_signature = $a_flag;
1389 return $DIC->mail()->signature()->installation();
1396 $lang = ($a_language instanceof
ilLanguage) ? $a_language : $DIC->language();
1397 $lang->loadLanguageModule(
'mail');
1400 $gender = $gender ?:
'n';
1403 if ($name[
'firstname'] ===
'') {
1404 return $lang->txt(
'mail_salutation_anonymous') .
',';
1408 $lang->txt(
'mail_salutation_' . $gender) .
' ' .
1409 ($name[
'title'] ? $name[
'title'] .
' ' :
'') .
1410 ($name[
'firstname'] ? $name[
'firstname'] .
' ' :
'') .
1411 $name[
'lastname'] .
',';
1416 if (!array_key_exists($usrId, $this->user_instances_by_id_map)) {
1423 $this->user_instances_by_id_map[$usrId] = $user;
1426 return $this->user_instances_by_id_map[$usrId];
1434 $this->user_instances_by_id_map = $userInstanceByIdMap;
1439 if (!isset($this->mail_options_by_usr_id_map[$usrId])) {
1440 $this->mail_options_by_usr_id_map[$usrId] =
new ilMailOptions($usrId);
1443 return $this->mail_options_by_usr_id_map[$usrId];
1451 $this->mail_options_by_usr_id_map = $mailOptionsByUsrIdMap;
1465 $this->legal_documents
setSaveInSentbox(bool $saveInSentbox)
formatLinebreakMessage(string $message)
sendMailWithReplacedPlaceholder(MailDeliveryData $mail_data, array $to_usr_ids)
getEmailRecipients(string $recipients)
int $max_recipient_character_length
persistToStage(int $a_user_id, array $a_attachments, string $a_rcp_to, string $a_rcp_cc, string $a_rcp_bcc, string $a_m_subject, string $a_m_message, bool $a_use_placeholders=false, ?string $a_tpl_context_id=null, ?array $a_tpl_ctx_params=[])
countMailsOfFolder(int $folderId)
static getLogger(string $a_component_id)
Get component logger.
markUnread(array $mailIds)
This class handles all operations on files (attachments) in directory ilias_data/mail.
appendInstallationSignature(bool $a_flag=null)
checkMail(string $to, string $cc, string $bcc, string $subject)
existsRecipient(string $newRecipient, string $existingRecipients)
getCountRecipients(string $toRecipients, string $ccRecipients, string $bccRecipients, bool $onlyExternalAddresses=true)
MailSignatureService $signature_service
getMailsOfFolder(int $a_folder_id, array $filter=[])
const PROP_CONTEXT_SUBJECT_PREFIX
sendMimeMail(string $to, string $cc, string $bcc, string $subject, string $message, array $attachments)
enqueue(string $a_rcp_to, string $a_rcp_cc, string $a_rcp_bcc, string $a_m_subject, string $a_m_message, array $a_attachment, bool $a_use_placeholders=false)
Should be used to enqueue a 'mail'.
getUserInstanceById(int $usrId)
static _lookupName(int $a_user_id)
lookup user name
static _lookupId($a_user_str)
static _getIliasMailerName()
Class ilMailOnlyExternalAddressList.
deleteMailsOfFolder(int $folderId)
static _lookupPref(int $a_usr_id, string $a_keyword)
array $mail_options_by_usr_id_map
saveInSentbox(array $attachment, string $to, string $cc, string $bcc, string $subject, string $message)
getPreviousMail(int $mailId)
sendChanneledMails(MailDeliveryData $mail_data, array $recipients, string $message)
static _lookupGender(int $a_user_id)
Class ilMailDiffAddressList.
getCountRecipient(string $recipients, bool $onlyExternalAddresses=true)
bool $append_installation_signature
readonly Conductor $legal_documents
static getTemplateContextById(string $a_id)
withContextParameters(array $parameters)
array $user_instances_by_id_map
saveAttachments(array $attachments)
static strLen(string $a_string)
Class ilMailRfc822AddressParserFactory.
array $context_parameters
delegateExternalEmails(string $subject, array $attachments, string $message, array $usrIdToExternalEmailAddressesMap)
const ILIAS_VERSION_NUMERIC
replacePlaceholdersEmpty(string $message)
fetchMailData(?array $row)
withContextId(string $contextId)
Mail Box class Base class for creating and handling mail boxes.
static getSalutation(int $a_usr_id, ?ilLanguage $a_language=null)
checkRecipients(string $recipients)
distributeMail(MailDeliveryData $mail_data)
replacePlaceholders(string $message, int $usrId=0)
getMailOptionsByUserId(int $usrId)
bool $append_user_signature
setUserInstanceById(array $userInstanceByIdMap)
sendMailWithReplacedEmptyPlaceholder(MailDeliveryData $mail_data, array $recipients,)
static _getLanguage(string $a_lang_key='')
Get language object.
Class ilMailTemplatePlaceholderResolver.
getMailObjectReferenceId()
__construct(private int $a_user_id, private ?ilMailAddressTypeFactory $mail_address_type_factory=null, private ilMailRfc822AddressParserFactory $mail_address_parser_factory=new ilMailRfc822AddressParserFactory(), private ?ilAppEventHandler $event_handler=null, private ?ilLogger $logger=null, private ?ilDBInterface $db=null, private ?ilLanguage $lng=null, private ?ilFileDataMail $mail_file_data=null, protected ?ilMailOptions $mail_options=null, private ?ilMailbox $mailbox=null, private ?ilMailMimeSenderFactory $sender_factory=null, private ?Closure $usr_id_by_login_callable=null, private ?AutoresponderService $auto_responder_service=null, private ?int $mail_admin_node_ref_id=null, private ?int $mail_obj_ref_id=null, private ?ilObjUser $actor=null, private ?ilMailTemplatePlaceholderResolver $placeholder_resolver=null, private ?ilMailTemplatePlaceholderToEmptyResolver $placeholder_to_empty_resolver=null, ?Conductor $legal_documents=null, ?MailSignatureService $signature_service=null,)
validateRecipients(string $to, string $cc, string $bcc)
getNewDraftId(int $folderId)
sendMail(MailDeliveryData $mail_data)
This method is used to finally send internal messages and external emails To use the mail system as a...
createRecipient(int $user_id)
sendMailWithoutReplacedPlaceholder(MailDeliveryData $mail_data, array $to_usr_ids, array $cc_bcc_recipients)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
formatNamesForOutput(string $recipients)
deleteMails(array $mailIds)
static _getAutoGeneratedMessageString(ilLanguage $lang=null)
static getMailObjectRefId()
setMailOptionsByUserIdMap(array $mailOptionsByUsrIdMap)
withInternalMailId(int $internal_mail_id)
sendInternalMail(int $folderId, int $senderUsrId, array $attachments, string $to, string $cc, string $bcc, string $status, string $subject, string $message, int $usrId=0, bool $usePlaceholders=false, ?string $templateContextId=null, array $templateContextParameters=[])
getUserIds(array $recipients)
static getType()
Get context type.
parseAddresses(string $addresses)
Explode recipient string, allowed separators are ',' ';' ' '.
Class ilMailAddressTypeFactory.
updateDraft(int $a_folder_id, array $a_attachments, string $a_rcp_to, string $a_rcp_cc, string $a_rcp_bcc, string $a_m_subject, string $a_m_message, int $a_draft_id=0, bool $a_use_placeholders=false, ?string $a_tpl_context_id=null, array $a_tpl_context_params=[])
moveMailsToFolder(array $mailIds, int $folderId)
readMailObjectReferenceId()
static _getInstallationSignature()
Class ilMailAddressListImpl.