19 declare(strict_types=1);
54 private int $a_user_id,
67 private ?
int $mail_admin_node_ref_id =
null,
68 private ?
int $mail_obj_ref_id =
null,
78 $this->event_handler = $event_handler ?? $DIC->event();
79 $this->db = $db ?? $DIC->database();
80 $this->
lng =
$lng ?? $DIC->language();
81 $this->actor = $actor ?? $DIC->user();
82 $this->mail_file_data = $mail_file_data ??
new ilFileDataMail($a_user_id);
83 $this->mail_options = $mail_options ??
new ilMailOptions($a_user_id);
84 $this->mailbox = $mailbox ??
new ilMailbox($a_user_id);
86 $this->sender_factory = $sender_factory ?? $DIC->mail()->mime()->senderFactory();
87 $this->usr_id_by_login_callable = $usr_id_by_login_callable ?? (
static fn(
string $login):
int => (
int)
ilObjUser::_lookupId($login));
88 $this->auto_responder_service = $auto_responder_service ?? $DIC->mail()->autoresponder();
89 $this->user_id = $a_user_id;
90 if ($this->mail_obj_ref_id ===
null) {
93 $this->
lng->loadLanguageModule(
'mail');
94 $this->table_mail =
'mail';
95 $this->table_mail_saved =
'mail_saved';
97 $this->placeholder_resolver = $placeholder_resolver ?? $DIC->mail()->placeholderResolver();
98 $this->placeholder_to_empty_resolver = $placeholder_to_empty_resolver ?? $DIC->mail()->placeholderToEmptyResolver();
99 $this->legal_documents = $legal_documents ?? $DIC[
'legalDocuments'];
100 $this->signature_service = $signature_service ?? $DIC->mail()->signature();
105 return $this->auto_responder_service;
110 $clone = clone $this;
119 $clone = clone $this;
121 $clone->context_parameters = $parameters;
131 public function existsRecipient(
string $new_recipient,
string $existing_recipients): bool
137 $diffed_addresses = $list->value();
139 return $diffed_addresses === [];
159 return $this->mail_obj_ref_id;
164 $recipients = trim($recipients);
165 if ($recipients ===
'') {
166 return $this->
lng->txt(
'not_available');
171 $recipients = array_filter(
array_map(
'trim', explode(
',', $recipients)));
172 foreach ($recipients as $recipient) {
174 if (is_int($usr_id) && $usr_id > 0) {
176 if ($pp ===
'g' || ($pp ===
'y' && !$this->actor->isAnonymous())) {
179 $names[] = $user->getFullname() .
' [' . $recipient .
']';
185 $names[] = $recipient;
188 return implode(
', ', $names);
193 $this->db->setLimit(1, 0);
195 $query = implode(
' ', [
196 "SELECT b.* FROM $this->table_mail a",
197 "INNER JOIN $this->table_mail b ON b.folder_id = a.folder_id",
198 'AND b.user_id = a.user_id AND b.send_time > a.send_time',
199 'WHERE a.user_id = %s AND a.mail_id = %s ORDER BY b.send_time ASC',
201 $res = $this->db->queryF(
203 [
'integer',
'integer'],
204 [$this->user_id, $mail_id]
214 $this->db->setLimit(1, 0);
216 $query = implode(
' ', [
217 "SELECT b.* FROM $this->table_mail a",
218 "INNER JOIN $this->table_mail b ON b.folder_id = a.folder_id",
219 'AND b.user_id = a.user_id AND b.send_time < a.send_time',
220 'WHERE a.user_id = %s AND a.mail_id = %s ORDER BY b.send_time DESC',
222 $res = $this->db->queryF(
224 [
'integer',
'integer'],
225 [$this->user_id, $mail_id]
238 'SELECT sender_id, m_subject, mail_id, m_status, send_time, import_name ' .
239 "FROM $this->table_mail " .
240 'LEFT JOIN object_data ON obj_id = sender_id ' .
241 'WHERE user_id = %s AND folder_id = %s ' .
242 'AND ((sender_id > 0 AND sender_id IS NOT NULL AND obj_id IS NOT NULL) ' .
243 'OR (sender_id = 0 OR sender_id IS NULL))';
245 if (isset($filter[
'status']) && $filter[
'status'] !==
'') {
246 $query .=
' AND m_status = ' . $this->db->quote($filter[
'status'],
'text');
249 $query .=
' ORDER BY send_time DESC';
251 $res = $this->db->queryF(
253 [
'integer',
'integer'],
254 [$this->user_id, $a_folder_id]
257 while ($row = $this->db->fetchAssoc(
$res)) {
261 return array_filter($mails);
266 $res = $this->db->queryF(
267 "SELECT COUNT(*) FROM $this->table_mail WHERE user_id = %s AND folder_id = %s",
268 [
'integer',
'integer'],
269 [$this->user_id, $folder_id]
272 return $this->db->numRows(
$res);
278 foreach ($mails as $mail_data) {
285 $res = $this->db->queryF(
286 "SELECT * FROM $this->table_mail WHERE user_id = %s AND mail_id = %s",
287 [
'integer',
'integer'],
288 [$this->user_id, $mail_id]
304 $query =
"UPDATE $this->table_mail SET m_status = %s WHERE user_id = %s ";
306 $types[] =
'integer';
310 if ($mail_ids !== []) {
311 $query .=
' AND ' . $this->db->in(
'mail_id', $mail_ids,
false,
'integer');
314 $this->db->manipulateF($query, $types, $values);
325 $query =
"UPDATE $this->table_mail SET m_status = %s WHERE user_id = %s ";
327 $types[] =
'integer';
328 $values[] =
'unread';
331 if ($mail_ids !== []) {
332 $query .=
' AND ' . $this->db->in(
'mail_id', $mail_ids,
false,
'integer');
335 $this->db->manipulateF($query, $types, $values);
346 $mail_ids = array_filter(
array_map(intval(...), $mail_ids));
348 if ([] === $mail_ids) {
353 "UPDATE $this->table_mail " .
354 'INNER JOIN mail_obj_data ' .
355 'ON mail_obj_data.obj_id = %s AND mail_obj_data.user_id = %s ' .
356 "SET $this->table_mail.folder_id = mail_obj_data.obj_id " .
357 "WHERE $this->table_mail.user_id = %s";
358 $types[] =
'integer';
359 $types[] =
'integer';
360 $types[] =
'integer';
361 $values[] = $folder_id;
365 $query .=
' AND ' . $this->db->in(
'mail_id', $mail_ids,
false,
'integer');
367 $affected_rows = $this->db->manipulateF($query, $types, $values);
369 return $affected_rows > 0;
377 $mail_ids = array_filter(
array_map(
'intval', $mail_ids));
378 foreach ($mail_ids as
$id) {
379 $this->db->manipulateF(
380 "DELETE FROM $this->table_mail WHERE user_id = %s AND mail_id = %s",
381 [
'integer',
'integer'],
382 [$this->user_id, $id]
384 $this->mail_file_data->deassignAttachmentFromDirectory($id);
390 if (!is_array($row) || empty($row)) {
394 if (isset($row[
'attachments'])) {
395 $unserialized = unserialize(stripslashes((
string) $row[
'attachments']), [
'allowed_classes' =>
false]);
396 $row[
'attachments'] = is_array($unserialized) ? $unserialized : [];
398 $row[
'attachments'] = [];
401 if (isset($row[
'tpl_ctx_params']) && is_string($row[
'tpl_ctx_params'])) {
402 $decoded = json_decode($row[
'tpl_ctx_params'],
true, 512, JSON_THROW_ON_ERROR);
403 $row[
'tpl_ctx_params'] = (array) ($decoded ?? []);
405 $row[
'tpl_ctx_params'] = [];
408 if (isset($row[
'mail_id'])) {
409 $row[
'mail_id'] = (
int) $row[
'mail_id'];
412 if (isset($row[
'user_id'])) {
413 $row[
'user_id'] = (
int) $row[
'user_id'];
416 if (isset($row[
'folder_id'])) {
417 $row[
'folder_id'] = (
int) $row[
'folder_id'];
420 if (isset($row[
'sender_id'])) {
421 $row[
'sender_id'] = (
int) $row[
'sender_id'];
424 if (isset($row[
'use_placeholders'])) {
425 $row[
'use_placeholders'] = (bool) $row[
'use_placeholders'];
428 $null_to_string_properties = [
'm_subject',
'm_message',
'rcp_to',
'rcp_cc',
'rcp_bcc'];
429 foreach ($null_to_string_properties as $null_to_string_property) {
430 if (!isset($row[$null_to_string_property])) {
431 $row[$null_to_string_property] =
'';
440 $next_id = $this->db->nextId($this->table_mail);
441 $this->db->insert($this->table_mail, [
442 'mail_id' => [
'integer', $next_id],
443 'user_id' => [
'integer', $this->user_id],
444 'folder_id' => [
'integer', $folder_id],
445 'sender_id' => [
'integer', $this->user_id],
456 array $a_attachments,
463 bool $a_use_placeholders =
false,
464 ?
string $a_tpl_context_id =
null,
465 array $a_tpl_context_params = []
470 'folder_id' => [
'integer', $a_folder_id],
471 'attachments' => [
'clob', serialize($a_attachments)],
472 'send_time' => [
'timestamp', date(
'Y-m-d H:i:s')],
473 'rcp_to' => [
'clob', $a_rcp_to],
474 'rcp_cc' => [
'clob', $a_rcp_cc],
475 'rcp_bcc' => [
'clob', $a_rcp_bcc],
476 'm_status' => [
'text',
'read'],
477 'm_subject' => [
'text', $a_m_subject],
478 'm_message' => [
'clob', $a_m_message],
479 'use_placeholders' => [
'integer', (
int) $a_use_placeholders],
480 'tpl_ctx_id' => [
'text', $a_tpl_context_id],
481 'tpl_ctx_params' => [
'blob', json_encode($a_tpl_context_params, JSON_THROW_ON_ERROR)],
484 'mail_id' => [
'integer', $a_draft_id],
502 bool $use_placeholders =
false,
503 ?
string $template_contenxt_id =
null,
504 array $template_context_parameters = []
508 if ($use_placeholders) {
511 $message = str_ireplace([
'<br />',
'<br>',
'<br/>'],
"\n", $message);
513 $next_id = $this->db->nextId($this->table_mail);
514 $this->db->insert($this->table_mail, [
515 'mail_id' => [
'integer', $next_id],
516 'user_id' => [
'integer', $usr_id],
517 'folder_id' => [
'integer', $folder_id],
518 'sender_id' => [
'integer', $sender_usr_id],
519 'attachments' => [
'clob', serialize($attachments)],
520 'send_time' => [
'timestamp', date(
'Y-m-d H:i:s')],
521 'rcp_to' => [
'clob', $to],
522 'rcp_cc' => [
'clob', $cc],
523 'rcp_bcc' => [
'clob', $bcc],
524 'm_status' => [
'text', $status],
525 'm_subject' => [
'text', $subject],
526 'm_message' => [
'clob', $message],
527 'tpl_ctx_id' => [
'text', $template_contenxt_id],
528 'tpl_ctx_params' => [
'blob', json_encode($template_context_parameters, JSON_THROW_ON_ERROR)],
531 $sender_equals_reveiver = $usr_id === $this->mailbox->getUsrId();
532 $is_sent_folder_of_sender =
false;
533 if ($sender_equals_reveiver) {
535 $is_sent_folder_of_sender = $folder_id === $current_folder_id;
538 $raise_event = !$sender_equals_reveiver || !$is_sent_folder_of_sender;
541 $this->event_handler->raise(
'components/ILIAS/Mail',
'sentInternalMail', [
543 'subject' => $subject,
545 'from_usr_id' => $sender_usr_id,
546 'to_usr_id' => $usr_id,
561 if ($this->context_id) {
568 $message = $this->placeholder_resolver->resolve(
572 $this->context_parameters
575 $this->
logger->error(sprintf(
576 '%s has been called with invalid context: %s / %s',
579 $e->getTraceAsString()
588 return $this->placeholder_to_empty_resolver->resolve($message);
593 $this->auto_responder_service->emptyAutoresponderData();
595 $this->
logger->debug(sprintf(
596 'Parsed TO user ids from given recipients for serial letter notification: %s',
597 implode(
', ', $to_usr_ids)
605 $this->
logger->debug(sprintf(
606 'Parsed CC/BCC user ids from given recipients for serial letter notification: %s',
607 implode(
', ', $other_usr_ids)
617 $this->auto_responder_service->disableAutoresponder();
618 $this->auto_responder_service->handleAutoresponderMails($this->user_id);
630 foreach ($to_usr_ids as $user_id) {
662 array $cc_bcc_recipients
671 array_merge($to_recipients, $cc_bcc_recipients),
684 $usr_id_to_external_email_addresses_map = [];
686 foreach ($recipients as $recipient) {
687 if (!$recipient->isUser()) {
688 $this->
logger->critical(sprintf(
689 'Skipped recipient with id %s (User not found)',
690 $recipient->getUserId()
695 $can_read_internal = $recipient->evaluateInternalMailReadability();
696 if ($this->
isSystemMail() && !$can_read_internal->isOk()) {
697 $this->
logger->debug(sprintf(
698 'Skipped recipient with id %s and reason: %s',
699 $recipient->getUserId(),
700 is_string($can_read_internal->error()) ? $can_read_internal->error() : $can_read_internal->error()->getMessage()
705 if ($recipient->isUserActive() && !$recipient->isUserExpired()) {
706 if (!$can_read_internal->isOk() || $recipient->userWantsToReceiveExternalMails()) {
707 $email_addresses = $recipient->getExternalMailAddress();
708 $usr_id_to_external_email_addresses_map[$recipient->getUserId()] = $email_addresses;
710 if ($recipient->onlyToExternalMailAddress()) {
711 $this->
logger->debug(sprintf(
712 'Recipient with id %s will only receive external emails sent to: %s',
713 $recipient->getUserId(),
714 implode(
', ', $email_addresses)
719 $this->
logger->debug(sprintf(
720 'Recipient with id %s will additionally receive external emails ' .
721 '(because the user wants to receive it externally, or the user cannot did not accept ' .
722 'the legal documents) sent to: %s',
723 $recipient->getUserId(),
724 implode(
', ', $email_addresses)
727 $this->
logger->debug(sprintf(
728 'Recipient with id %s does not want to receive external emails',
729 $recipient->getUserId()
733 $this->
logger->debug(sprintf(
734 'Recipient with id %s is inactive or expired and will not receive external emails',
735 $recipient->getUserId()
739 $mbox = clone $this->mailbox;
740 $mbox->setUsrId($recipient->getUserId());
741 $recipient_inbox_id = $mbox->getInboxFolder();
753 $recipient->getUserId()
756 $this->auto_responder_service->enqueueAutoresponderIfEnabled(
757 $recipient->getUserId(),
758 $recipient->getMailOptions(),
763 $this->mail_file_data->assignAttachmentsToDirectory($internal_mail_id, $mail_data->
getInternalMailId());
771 $usr_id_to_external_email_addresses_map
783 array $usr_id_to_external_email_addresses_map
785 if (count($usr_id_to_external_email_addresses_map) === 1) {
786 $usr_id_to_external_email_addresses_map = array_values($usr_id_to_external_email_addresses_map);
787 $first_addresses = current($usr_id_to_external_email_addresses_map);
790 implode(
',', $first_addresses),
797 } elseif (count($usr_id_to_external_email_addresses_map) > 1) {
799 $usr_id_to_external_email_addresses_map
802 $flattened_email_addresses = array_unique($flattened_email_addresses);
805 $remaining_addresses =
'';
806 foreach ($flattened_email_addresses as $email_address) {
808 if ($remaining_addresses !==
'') {
812 $recipients_line_length =
ilStr::strLen($remaining_addresses) +
814 if ($recipients_line_length >= $this->max_recipient_character_length) {
818 $remaining_addresses,
824 $remaining_addresses =
'';
828 $remaining_addresses .= ($sep . $email_address);
831 if ($remaining_addresses !==
'') {
835 $remaining_addresses,
850 $parsed_usr_ids = [];
852 $joined_recipients = implode(
',', array_filter(
array_map(
'trim', $recipients)));
855 foreach ($addresses as $address) {
856 $address_type = $this->mail_address_type_factory->getByPrefix($address);
857 $parsed_usr_ids[] = $address_type->resolve();
860 return array_unique(array_merge(...$parsed_usr_ids));
866 private function checkMail(
string $to,
string $cc,
string $bcc,
string $subject): array
871 $subject =>
'mail_add_subject',
872 $to =>
'mail_add_recipient',
874 foreach ($checks as $string => $error) {
875 if ($string ===
'') {
882 $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 $position = strpos($e->getMessage(),
':');
906 ($position ===
false) ? $e->getMessage() : substr($e->getMessage(), $position + 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 'New mail system task:' .
987 ' To: ' . $a_rcp_to .
988 ' | CC: ' . $a_rcp_cc .
989 ' | BCC: ' . $a_rcp_bcc .
990 ' | Subject: ' . $a_m_subject .
991 ' | Attachments: ' . print_r($a_attachment,
true)
994 if ($a_attachment && !$this->mail_file_data->checkFilesExist($a_attachment)) {
995 return [
new ilMailError(
'mail_attachment_file_not_exist', [implode(
', ', $a_attachment)])];
998 $errors = $this->
checkMail($a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_m_subject);
999 if ($errors !== []) {
1004 if ($errors !== []) {
1008 $rcp_to = $a_rcp_to;
1009 $rcp_cc = $a_rcp_cc;
1010 $rcp_bcc = $a_rcp_bcc;
1012 $number_of_external_addresses = $this->
getCountRecipients($rcp_to, $rcp_cc, $rcp_bcc);
1014 $number_of_external_addresses > 0 &&
1016 !$DIC->rbac()->system()->checkAccessOfUser($this->user_id,
'smtp_mail', $this->mail_obj_ref_id)
1018 return [
new ilMailError(
'mail_no_permissions_write_smtp')];
1022 $a_m_message .= self::_getInstallationSignature();
1035 return $this->
sendMail($mail_data);
1038 $task_factory = $DIC->backgroundTasks()->taskFactory();
1039 $task_manager = $DIC->backgroundTasks()->taskManager();
1042 $bucket->setUserId($this->user_id);
1044 $task = $task_factory->createTask(ilMailDeliveryJob::class, [
1051 serialize($a_attachment),
1052 $a_use_placeholders,
1054 (
string) $this->context_id,
1055 serialize(array_merge(
1056 $this->context_parameters,
1058 'auto_responder' => $this->auto_responder_service->isAutoresponderEnabled()
1062 $interaction = $task_factory->createTask(ilMailDeliveryJobUserInteraction::class, [
1067 $bucket->setTask($interaction);
1068 $bucket->setTitle($this->
lng->txt(
'mail_bg_task_title'));
1069 $bucket->setDescription(sprintf($this->
lng->txt(
'mail_bg_task_desc'), $a_m_subject));
1071 $this->
logger->info(
'Delegated delivery to background task');
1072 $task_manager->run($bucket);
1090 $mail_data->
getTo(),
1091 $mail_data->
getCc(),
1098 if ($mail_data->getAttachments() !== []) {
1099 $this->mail_file_data->assignAttachmentsToDirectory($internal_message_id, $internal_message_id);
1100 $this->mail_file_data->saveFiles($internal_message_id, $mail_data->getAttachments());
1104 $mail_data->getTo(),
1105 $mail_data->getCc(),
1106 $mail_data->getBcc()
1109 if ($num_external_email_addresses > 0) {
1115 'Parsed external email addresses from given recipients /' .
1116 ' To: ' . $external_mail_recipients_to .
1117 ' | CC: ' . $external_mail_recipients_cc .
1118 ' | BCC: ' . $external_eail_recipients_bcc .
1119 ' | Subject: ' . $mail_data->getSubject()
1123 $external_mail_recipients_to,
1124 $external_mail_recipients_cc,
1125 $external_eail_recipients_bcc,
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');
1138 $errors[
'mail_send_error'] =
new ilMailError(
'mail_send_error');
1146 $random =
new Random\Randomizer();
1147 if ($random->getInt(0, 50) === 2) {
1150 $this->mail_file_data
1155 return array_values($errors);
1169 if ($errors !== []) {
1170 return array_merge([
new ilMailError(
'mail_following_rcp_not_valid')], $errors);
1173 return [
new ilMailError(
'mail_generic_rcp_error', [$e->getMessage()])];
1181 $send_folder_id = 0;
1183 $send_folder_id = $this->mailbox->getSentFolder();
1186 return $send_folder_id;
1226 $mailer->From($this->sender_factory->getSenderByUsrId($this->user_id));
1231 (
string) ($this->context_parameters[self::PROP_CONTEXT_SUBJECT_PREFIX] ??
'')
1235 $message .= $this->signature_service->user($this->user_id);
1237 $mailer->Body($message);
1248 foreach ($attachments as $attachment) {
1250 $this->mail_file_data->getAbsoluteAttachmentPoolPathByFilename($attachment),
1266 $this->table_mail_saved,
1268 'attachments' => [
'clob', serialize($attachments)],
1271 'user_id' => [
'integer', $this->user_id],
1282 if ($addresses !==
'') {
1283 $this->
logger->debug(sprintf(
1284 'Started parsing of recipient string: %s',
1289 $parser = $this->mail_address_parser_factory->getParser($addresses);
1290 $parsed_addresses = $parser->parse();
1292 if ($addresses !==
'') {
1293 $this->
logger->debug(sprintf(
1294 'Parsed addresses: %s',
1295 implode(
',',
array_map(
static fn(
ilMailAddress $address):
string => (
string) $address, $parsed_addresses))
1299 return $parsed_addresses;
1305 if ($only_external_addresses) {
1309 $this->usr_id_by_login_callable
1313 return count($addresses->value());
1317 string $to_recipients,
1318 string $cc_recipients,
1319 string $bcc_recipients,
1320 bool $only_external_addresses =
true 1334 $this->usr_id_by_login_callable
1337 $email_recipients =
array_map(
static fn(
ilMailAddress $address):
string => (
string) $address, $addresses->value());
1339 return implode(
',', $email_recipients);
1350 $lang->loadLanguageModule(
'mail');
1353 $lang->txt(
'mail_auto_generated_info'),
1362 $sender_factory = $DIC->mail()->mime()->senderFactory();
1364 return $sender_factory->system()->getFromName();
1372 if ($a_flag ===
null) {
1376 $this->append_installation_signature = $a_flag;
1383 return $DIC->mail()->signature()->installation();
1390 $lang = ($a_language instanceof
ilLanguage) ? $a_language : $DIC->language();
1391 $lang->loadLanguageModule(
'mail');
1394 $gender = $gender ?:
'n';
1397 if ($name[
'firstname'] ===
'') {
1398 return $lang->txt(
'mail_salutation_anonymous') .
',';
1402 $lang->txt(
'mail_salutation_' . $gender) .
' ' .
1403 ($name[
'title'] ? $name[
'title'] .
' ' :
'') .
1404 ($name[
'firstname'] ? $name[
'firstname'] .
' ' :
'') .
1405 $name[
'lastname'] .
',';
1410 if (!array_key_exists($usr_id, $this->user_instances_by_id_map)) {
1417 $this->user_instances_by_id_map[$usr_id] = $user;
1420 return $this->user_instances_by_id_map[$usr_id];
1433 if (!isset($this->mail_options_by_usr_id_map[$usr_id])) {
1434 $this->mail_options_by_usr_id_map[$usr_id] =
new ilMailOptions($usr_id);
1437 return $this->mail_options_by_usr_id_map[$usr_id];
1459 $this->legal_documents
replacePlaceholders(string $message, int $usr_id=0)
formatLinebreakMessage(string $message)
moveMailsToFolder(array $mail_ids, int $folder_id)
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=[])
markUnread(array $mail_ids)
static getLogger(string $a_component_id)
Get component logger.
getCountRecipients(string $to_recipients, string $cc_recipients, string $bcc_recipients, bool $only_external_addresses=true)
checkMail(string $to, string $cc, string $bcc, string $subject)
MailSignatureService $signature_service
getMailsOfFolder(int $a_folder_id, array $filter=[])
appendInstallationSignature(?bool $a_flag=null)
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'.
static _lookupName(int $a_user_id)
lookup user name
static _lookupId($a_user_str)
static _getIliasMailerName()
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)
markRead(array $mail_ids)
getNextMail(int $mail_id)
sendChanneledMails(MailDeliveryData $mail_data, array $recipients, string $message)
static _lookupGender(int $a_user_id)
setUserInstanceById(array $user_instances_by_id_map)
setSaveInSentbox(bool $save_in_sentbox)
bool $append_installation_signature
readonly Conductor $legal_documents
static _getAutoGeneratedMessageString(?ilLanguage $lang=null)
static getTemplateContextById(string $a_id)
withContextParameters(array $parameters)
sendInternalMail(int $folder_id, int $sender_usr_id, array $attachments, string $to, string $cc, string $bcc, string $status, string $subject, string $message, int $usr_id=0, bool $use_placeholders=false, ?string $template_contenxt_id=null, array $template_context_parameters=[])
getMailOptionsByUserId(int $usr_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
array $user_instances_by_id_map
deleteMailsOfFolder(int $folder_id)
saveAttachments(array $attachments)
static strLen(string $a_string)
array $context_parameters
const ILIAS_VERSION_NUMERIC
getPreviousMail(int $mail_id)
replacePlaceholdersEmpty(string $message)
fetchMailData(?array $row)
setMailOptionsByUserIdMap(array $mail_options_by_usr_id_map)
static getSalutation(int $a_usr_id, ?ilLanguage $a_language=null)
checkRecipients(string $recipients)
distributeMail(MailDeliveryData $mail_data)
bool $append_user_signature
sendMailWithReplacedEmptyPlaceholder(MailDeliveryData $mail_data, array $recipients,)
static _getLanguage(string $a_lang_key='')
Get language object.
getMailObjectReferenceId()
const string PROP_CONTEXT_SUBJECT_PREFIX
existsRecipient(string $new_recipient, string $existing_recipients)
__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)
withContextId(string $context_id)
sendMail(MailDeliveryData $mail_data)
This method is used to finally send internal messages and external emails To use the mail system as a...
deleteMails(array $mail_ids)
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)
static getMailObjectRefId()
withInternalMailId(int $internal_mail_id)
getUserIds(array $recipients)
static getType()
Get context type.
delegateExternalEmails(string $subject, array $attachments, string $message, array $usr_id_to_external_email_addresses_map)
parseAddresses(string $addresses)
Explode recipient string, allowed separators are ',' ';' ' '.
countMailsOfFolder(int $folder_id)
getUserInstanceById(int $usr_id)
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=[])
readMailObjectReferenceId()
static _getInstallationSignature()
getNewDraftId(int $folder_id)
getCountRecipient(string $recipients, bool $only_external_addresses=true)