19 declare(strict_types=1);
58 private int $a_user_id,
71 private ?
int $mail_admin_node_ref_id =
null,
72 private ?
int $mail_obj_ref_id =
null,
82 $this->event_handler = $event_handler ?? $DIC->event();
83 $this->db = $db ?? $DIC->database();
84 $this->
lng =
$lng ?? $DIC->language();
85 $this->actor = $actor ?? $DIC->user();
86 $this->mail_file_data = $mail_file_data ??
new ilFileDataMail($a_user_id);
87 $this->mail_options = $mail_options ??
new ilMailOptions($a_user_id);
88 $this->mailbox = $mailbox ??
new ilMailbox($a_user_id);
90 $this->sender_factory = $sender_factory ?? $DIC->mail()->mime()->senderFactory();
91 $this->usr_id_by_login_callable = $usr_id_by_login_callable ??
static function (
string $login):
int {
94 $this->auto_responder_service = $auto_responder_service ?? $DIC->mail()->autoresponder();
95 $this->user_id = $a_user_id;
96 if (
null === $this->mail_obj_ref_id) {
99 $this->
lng->loadLanguageModule(
'mail');
100 $this->table_mail =
'mail';
101 $this->table_mail_saved =
'mail_saved';
103 $this->placeholder_resolver = $placeholder_resolver ?? $DIC->mail()->placeholderResolver();
104 $this->placeholder_to_empty_resolver = $placeholder_to_empty_resolver ?? $DIC->mail()->placeholderToEmptyResolver();
105 $this->legal_documents = $legal_documents ?? $DIC[
'legalDocuments'];
106 $this->signature_service = $signature_service ?? $DIC->mail()->signature();
111 return $this->auto_responder_service;
116 $clone = clone $this;
118 $clone->context_id = $contextId;
125 $clone = clone $this;
127 $clone->context_parameters = $parameters;
137 public function existsRecipient(
string $newRecipient,
string $existingRecipients): bool
144 $diffedAddresses = $list->value();
146 return $diffedAddresses === [];
151 $this->save_in_sentbox = $saveInSentbox;
166 return $this->mail_obj_ref_id;
171 $recipients = trim($recipients);
172 if ($recipients ===
'') {
173 return $this->
lng->txt(
'not_available');
178 $recipients = array_filter(
array_map(
'trim', explode(
',', $recipients)));
179 foreach ($recipients as $recipient) {
181 if (is_int($usrId) && $usrId > 0) {
183 if ($pp ===
'g' || ($pp ===
'y' && !$this->actor->isAnonymous())) {
186 $names[] = $user->getFullname() .
' [' . $recipient .
']';
192 $names[] = $recipient;
195 return implode(
', ', $names);
200 $this->db->setLimit(1, 0);
202 $query = implode(
' ', [
203 "SELECT b.* FROM $this->table_mail a",
204 "INNER JOIN $this->table_mail b ON b.folder_id = a.folder_id",
205 'AND b.user_id = a.user_id AND b.send_time > a.send_time',
206 'WHERE a.user_id = %s AND a.mail_id = %s ORDER BY b.send_time ASC',
208 $res = $this->db->queryF(
210 [
'integer',
'integer'],
211 [$this->user_id, $mailId]
221 $this->db->setLimit(1, 0);
223 $query = implode(
' ', [
224 "SELECT b.* FROM $this->table_mail a",
225 "INNER JOIN $this->table_mail b ON b.folder_id = a.folder_id",
226 'AND b.user_id = a.user_id AND b.send_time < a.send_time',
227 'WHERE a.user_id = %s AND a.mail_id = %s ORDER BY b.send_time DESC',
229 $res = $this->db->queryF(
231 [
'integer',
'integer'],
232 [$this->user_id, $mailId]
245 "SELECT sender_id, m_subject, mail_id, m_status, send_time, import_name " .
246 "FROM $this->table_mail " .
247 "LEFT JOIN object_data ON obj_id = sender_id " .
248 "WHERE user_id = %s AND folder_id = %s " .
249 "AND ((sender_id > 0 AND sender_id IS NOT NULL AND obj_id IS NOT NULL) " .
250 "OR (sender_id = 0 OR sender_id IS NULL))";
252 if (isset($filter[
'status']) && $filter[
'status'] !==
'') {
253 $query .=
' AND m_status = ' . $this->db->quote($filter[
'status'],
'text');
256 $query .=
" ORDER BY send_time DESC";
258 $res = $this->db->queryF(
260 [
'integer',
'integer'],
261 [$this->user_id, $a_folder_id]
264 while ($row = $this->db->fetchAssoc(
$res)) {
268 return array_filter($mails);
273 $res = $this->db->queryF(
274 "SELECT COUNT(*) FROM $this->table_mail WHERE user_id = %s AND folder_id = %s",
275 [
'integer',
'integer'],
276 [$this->user_id, $folderId]
279 return $this->db->numRows(
$res);
285 foreach ($mails as $mail_data) {
292 $res = $this->db->queryF(
293 "SELECT * FROM $this->table_mail WHERE user_id = %s AND mail_id = %s",
294 [
'integer',
'integer'],
295 [$this->user_id, $mailId]
311 $query =
"UPDATE $this->table_mail SET m_status = %s WHERE user_id = %s ";
313 $types[] =
'integer';
317 if ($mailIds !== []) {
318 $query .=
' AND ' . $this->db->in(
'mail_id', $mailIds,
false,
'integer');
321 $this->db->manipulateF($query, $types, $values);
332 $query =
"UPDATE $this->table_mail SET m_status = %s WHERE user_id = %s ";
334 $types[] =
'integer';
335 $values[] =
'unread';
338 if ($mailIds !== []) {
339 $query .=
' AND ' . $this->db->in(
'mail_id', $mailIds,
false,
'integer');
342 $this->db->manipulateF($query, $types, $values);
353 $mailIds = array_filter(
array_map(
'intval', $mailIds));
355 if ([] === $mailIds) {
360 "UPDATE $this->table_mail " .
361 "INNER JOIN mail_obj_data " .
362 "ON mail_obj_data.obj_id = %s AND mail_obj_data.user_id = %s " .
363 "SET $this->table_mail.folder_id = mail_obj_data.obj_id " .
364 "WHERE $this->table_mail.user_id = %s";
365 $types[] =
'integer';
366 $types[] =
'integer';
367 $types[] =
'integer';
368 $values[] = $folderId;
372 $query .=
' AND ' . $this->db->in(
'mail_id', $mailIds,
false,
'integer');
374 $affectedRows = $this->db->manipulateF($query, $types, $values);
376 return $affectedRows > 0;
384 $mailIds = array_filter(
array_map(
'intval', $mailIds));
385 foreach ($mailIds as
$id) {
386 $this->db->manipulateF(
387 "DELETE FROM $this->table_mail WHERE user_id = %s AND mail_id = %s",
388 [
'integer',
'integer'],
389 [$this->user_id, $id]
391 $this->mail_file_data->deassignAttachmentFromDirectory($id);
397 if (!is_array($row) || empty($row)) {
401 if (isset($row[
'attachments'])) {
402 $unserialized = unserialize(stripslashes($row[
'attachments']), [
'allowed_classes' =>
false]);
403 $row[
'attachments'] = is_array($unserialized) ? $unserialized : [];
405 $row[
'attachments'] = [];
408 if (isset($row[
'tpl_ctx_params']) && is_string($row[
'tpl_ctx_params'])) {
409 $decoded = json_decode($row[
'tpl_ctx_params'],
true, 512, JSON_THROW_ON_ERROR);
410 $row[
'tpl_ctx_params'] = (array) ($decoded ?? []);
412 $row[
'tpl_ctx_params'] = [];
415 if (isset($row[
'mail_id'])) {
416 $row[
'mail_id'] = (
int) $row[
'mail_id'];
419 if (isset($row[
'user_id'])) {
420 $row[
'user_id'] = (
int) $row[
'user_id'];
423 if (isset($row[
'folder_id'])) {
424 $row[
'folder_id'] = (
int) $row[
'folder_id'];
427 if (isset($row[
'sender_id'])) {
428 $row[
'sender_id'] = (
int) $row[
'sender_id'];
431 if (isset($row[
'use_placeholders'])) {
432 $row[
'use_placeholders'] = (bool) $row[
'use_placeholders'];
435 $null_to_string_properties = [
'm_subject',
'm_message',
'rcp_to',
'rcp_cc',
'rcp_bcc'];
436 foreach ($null_to_string_properties as $null_to_string_property) {
437 if (!isset($row[$null_to_string_property])) {
438 $row[$null_to_string_property] =
'';
447 $nextId = $this->db->nextId($this->table_mail);
448 $this->db->insert($this->table_mail, [
449 'mail_id' => [
'integer', $nextId],
450 'user_id' => [
'integer', $this->user_id],
451 'folder_id' => [
'integer', $folderId],
452 'sender_id' => [
'integer', $this->user_id],
463 array $a_attachments,
470 bool $a_use_placeholders =
false,
471 ?
string $a_tpl_context_id =
null,
472 array $a_tpl_context_params = []
477 'folder_id' => [
'integer', $a_folder_id],
478 'attachments' => [
'clob', serialize($a_attachments)],
479 'send_time' => [
'timestamp', date(
'Y-m-d H:i:s')],
480 'rcp_to' => [
'clob', $a_rcp_to],
481 'rcp_cc' => [
'clob', $a_rcp_cc],
482 'rcp_bcc' => [
'clob', $a_rcp_bcc],
483 'm_status' => [
'text',
'read'],
484 'm_subject' => [
'text', $a_m_subject],
485 'm_message' => [
'clob', $a_m_message],
486 'use_placeholders' => [
'integer', (
int) $a_use_placeholders],
487 'tpl_ctx_id' => [
'text', $a_tpl_context_id],
488 'tpl_ctx_params' => [
'blob', json_encode($a_tpl_context_params, JSON_THROW_ON_ERROR)],
491 'mail_id' => [
'integer', $a_draft_id],
509 bool $usePlaceholders =
false,
510 ?
string $templateContextId =
null,
511 array $templateContextParameters = []
515 if ($usePlaceholders) {
518 $message = str_ireplace([
"<br />",
"<br>",
"<br/>"],
"\n", $message);
520 $nextId = $this->db->nextId($this->table_mail);
521 $this->db->insert($this->table_mail, [
522 'mail_id' => [
'integer', $nextId],
523 'user_id' => [
'integer', $usrId],
524 'folder_id' => [
'integer', $folderId],
525 'sender_id' => [
'integer', $senderUsrId],
526 'attachments' => [
'clob', serialize($attachments)],
527 'send_time' => [
'timestamp', date(
'Y-m-d H:i:s')],
528 'rcp_to' => [
'clob', $to],
529 'rcp_cc' => [
'clob', $cc],
530 'rcp_bcc' => [
'clob', $bcc],
531 'm_status' => [
'text', $status],
532 'm_subject' => [
'text', $subject],
533 'm_message' => [
'clob', $message],
534 'tpl_ctx_id' => [
'text', $templateContextId],
535 'tpl_ctx_params' => [
'blob', json_encode($templateContextParameters, JSON_THROW_ON_ERROR)],
538 $sender_equals_reveiver = $usrId === $this->mailbox->getUsrId();
539 $is_sent_folder_of_sender =
false;
540 if ($sender_equals_reveiver) {
542 $is_sent_folder_of_sender = $folderId === $current_folder_id;
545 $raise_event = !$sender_equals_reveiver || !$is_sent_folder_of_sender;
548 $this->event_handler->raise(
'components/ILIAS/Mail',
'sentInternalMail', [
550 'subject' => $subject,
552 'from_usr_id' => $senderUsrId,
553 'to_usr_id' => $usrId,
568 if ($this->context_id) {
575 $message = $this->placeholder_resolver->resolve(
579 $this->context_parameters
582 $this->
logger->error(sprintf(
583 '%s has been called with invalid context: %s / %s',
586 $e->getTraceAsString()
595 return $this->placeholder_to_empty_resolver->resolve($message);
600 $this->auto_responder_service->emptyAutoresponderData();
602 $this->
logger->debug(sprintf(
603 "Parsed TO user ids from given recipients for serial letter notification: %s",
604 implode(
', ', $to_usr_ids)
612 $this->
logger->debug(sprintf(
613 "Parsed CC/BCC user ids from given recipients for serial letter notification: %s",
614 implode(
', ', $other_usr_ids)
624 $this->auto_responder_service->disableAutoresponder();
625 $this->auto_responder_service->handleAutoresponderMails($this->user_id);
634 foreach ($to_usr_ids as $user_id) {
659 array $cc_bcc_recipients
668 array_merge($to_recipients, $cc_bcc_recipients),
682 $usrIdToExternalEmailAddressesMap = [];
684 foreach ($recipients as $recipient) {
685 if (!$recipient->isUser()) {
686 $this->
logger->critical(sprintf(
687 "Skipped recipient with id %s (User not found)",
688 $recipient->getUserId()
693 $can_read_internal = $recipient->evaluateInternalMailReadability();
694 if ($this->
isSystemMail() && !$can_read_internal->isOk()) {
695 $this->
logger->debug(sprintf(
696 'Skipped recipient with id %s and reason: %s',
697 $recipient->getUserId(),
698 is_string($can_read_internal->error()) ? $can_read_internal->error() : $can_read_internal->error()->getMessage()
703 if ($recipient->isUserActive()) {
704 if (!$can_read_internal->isOk() || $recipient->userWantsToReceiveExternalMails()) {
705 $emailAddresses = $recipient->getExternalMailAddress();
706 $usrIdToExternalEmailAddressesMap[$recipient->getUserId()] = $emailAddresses;
708 if ($recipient->onlyToExternalMailAddress()) {
709 $this->
logger->debug(sprintf(
710 "Recipient with id %s will only receive external emails sent to: %s",
711 $recipient->getUserId(),
712 implode(
', ', $emailAddresses)
717 $this->
logger->debug(sprintf(
718 "Recipient with id %s will additionally receive external emails " .
719 "(because the user wants to receive it externally, or the user cannot access " .
720 "the internal mail system) sent to: %s",
721 $recipient->getUserId(),
722 implode(
', ', $emailAddresses)
725 $this->
logger->debug(sprintf(
726 "Recipient with id %s is does not want to receive external emails",
727 $recipient->getUserId()
731 $this->
logger->debug(sprintf(
732 "Recipient with id %s is inactive and will not receive external emails",
733 $recipient->getUserId()
737 $mbox = clone $this->mailbox;
738 $mbox->setUsrId($recipient->getUserId());
739 $recipientInboxId = $mbox->getInboxFolder();
751 $recipient->getUserId()
754 $this->auto_responder_service->enqueueAutoresponderIfEnabled(
755 $recipient->getUserId(),
756 $recipient->getMailOptions(),
761 $this->mail_file_data->assignAttachmentsToDirectory($internalMailId, $mail_data->
getInternalMailId());
769 $usrIdToExternalEmailAddressesMap
781 array $usrIdToExternalEmailAddressesMap
783 if (1 === count($usrIdToExternalEmailAddressesMap)) {
784 $usrIdToExternalEmailAddressesMap = array_values($usrIdToExternalEmailAddressesMap);
785 $firstAddresses = current($usrIdToExternalEmailAddressesMap);
788 implode(
',', $firstAddresses),
795 } elseif (count($usrIdToExternalEmailAddressesMap) > 1) {
797 $usrIdToExternalEmailAddressesMap
800 $flattenEmailAddresses = array_unique($flattenEmailAddresses);
803 $remainingAddresses =
'';
804 foreach ($flattenEmailAddresses as $emailAddress) {
806 if ($remainingAddresses !==
'') {
812 if ($recipientsLineLength >= $this->max_recipient_character_length) {
822 $remainingAddresses =
'';
826 $remainingAddresses .= ($sep . $emailAddress);
829 if (
'' !== $remainingAddresses) {
848 $parsed_usr_ids = [];
850 $joined_recipients = implode(
',', array_filter(
array_map(
'trim', $recipients)));
853 foreach ($addresses as $address) {
854 $address_type = $this->mail_address_type_factory->getByPrefix($address);
855 $parsed_usr_ids[] = $address_type->resolve();
858 return array_unique(array_merge(...$parsed_usr_ids));
864 private function checkMail(
string $to,
string $cc,
string $bcc,
string $subject): array
869 $subject =>
'mail_add_subject',
870 $to =>
'mail_add_recipient',
872 foreach ($checks as $string => $error) {
873 if ($string ===
'') {
880 $errors[] =
new ilMailError(
'mail_subject_too_long');
896 foreach ($addresses as $address) {
897 $address_type = $this->mail_address_type_factory->getByPrefix($address);
898 if (!$address_type->validate($this->user_id)) {
899 $errors[] = $address_type->getErrors();
903 $colonPosition = strpos($e->getMessage(),
':');
905 ($colonPosition ===
false) ? $e->getMessage() : substr($e->getMessage(), $colonPosition + 2),
911 return array_merge(...$errors);
919 array $a_attachments,
925 bool $a_use_placeholders =
false,
926 ?
string $a_tpl_context_id =
null,
927 ?array $a_tpl_ctx_params = []
930 $this->table_mail_saved,
932 'user_id' => [
'integer', $this->user_id],
935 'attachments' => [
'clob', serialize($a_attachments)],
936 'rcp_to' => [
'clob', $a_rcp_to],
937 'rcp_cc' => [
'clob', $a_rcp_cc],
938 'rcp_bcc' => [
'clob', $a_rcp_bcc],
939 'm_subject' => [
'text', $a_m_subject],
940 'm_message' => [
'clob', $a_m_message],
941 'use_placeholders' => [
'integer', (
int) $a_use_placeholders],
942 'tpl_ctx_id' => [
'text', $a_tpl_context_id],
943 'tpl_ctx_params' => [
'blob', json_encode((array) $a_tpl_ctx_params, JSON_THROW_ON_ERROR)],
954 $res = $this->db->queryF(
955 "SELECT * FROM $this->table_mail_saved WHERE user_id = %s",
961 if (!is_array($this->mail_data)) {
962 $this->
persistToStage($this->user_id, [],
'',
'',
'',
'',
'',
false);
980 bool $a_use_placeholders =
false 985 "New mail system task:" .
986 " To: " . $a_rcp_to .
987 " | CC: " . $a_rcp_cc .
988 " | BCC: " . $a_rcp_bcc .
989 " | Subject: " . $a_m_subject .
990 " | Attachments: " . print_r($a_attachment,
true)
993 if ($a_attachment && !$this->mail_file_data->checkFilesExist($a_attachment)) {
994 return [
new ilMailError(
'mail_attachment_file_not_exist', [$a_attachment])];
997 $errors = $this->
checkMail($a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_m_subject);
998 if ($errors !== []) {
1003 if ($errors !== []) {
1007 $rcp_to = $a_rcp_to;
1008 $rcp_cc = $a_rcp_cc;
1009 $rcp_bcc = $a_rcp_bcc;
1013 $numberOfExternalAddresses > 0 &&
1015 !$DIC->rbac()->system()->checkAccessOfUser($this->user_id,
'smtp_mail', $this->mail_obj_ref_id)
1017 return [
new ilMailError(
'mail_no_permissions_write_smtp')];
1021 $a_m_message .= self::_getInstallationSignature();
1034 return $this->
sendMail($mail_data);
1037 $taskFactory = $DIC->backgroundTasks()->taskFactory();
1038 $taskManager = $DIC->backgroundTasks()->taskManager();
1041 $bucket->setUserId($this->user_id);
1043 $task = $taskFactory->createTask(ilMailDeliveryJob::class, [
1050 serialize($a_attachment),
1051 $a_use_placeholders,
1053 (
string) $this->context_id,
1054 serialize(array_merge(
1055 $this->context_parameters,
1057 'auto_responder' => $this->auto_responder_service->isAutoresponderEnabled()
1061 $interaction = $taskFactory->createTask(ilMailDeliveryJobUserInteraction::class, [
1066 $bucket->setTask($interaction);
1067 $bucket->setTitle($this->
lng->txt(
'mail_bg_task_title'));
1068 $bucket->setDescription(sprintf($this->
lng->txt(
'mail_bg_task_desc'), $a_m_subject));
1070 $this->
logger->info(
'Delegated delivery to background task');
1071 $taskManager->run($bucket);
1089 $mail_data->
getTo(),
1090 $mail_data->
getCc(),
1097 if ($mail_data->getAttachments() !== []) {
1098 $this->mail_file_data->assignAttachmentsToDirectory($internalMessageId, $internalMessageId);
1099 $this->mail_file_data->saveFiles($internalMessageId, $mail_data->getAttachments());
1102 $numberOfExternalAddresses = $this->
getCountRecipients($mail_data->getTo(), $mail_data->getCc(), $mail_data->getBcc());
1104 if ($numberOfExternalAddresses > 0) {
1110 "Parsed external email addresses from given recipients /" .
1111 " To: " . $externalMailRecipientsTo .
1112 " | CC: " . $externalMailRecipientsCc .
1113 " | BCC: " . $externalMailRecipientsBcc .
1114 " | Subject: " . $mail_data->getSubject()
1118 $externalMailRecipientsTo,
1119 $externalMailRecipientsCc,
1120 $externalMailRecipientsBcc,
1121 $mail_data->getSubject(),
1122 $mail_data->isUsePlaceholder() ?
1124 $mail_data->getMessage(),
1125 $mail_data->getAttachments()
1128 $this->
logger->debug(
'No external email addresses given in recipient string');
1134 $errors[
'mail_send_error'] =
new ilMailError(
'mail_send_error');
1142 $random =
new Random\Randomizer();
1143 if ($random->getInt(0, 50) === 2) {
1146 $this->mail_file_data
1151 return array_values($errors);
1165 if ($errors !== []) {
1166 return array_merge([
new ilMailError(
'mail_following_rcp_not_valid')], $errors);
1169 return [
new ilMailError(
'mail_generic_rcp_error', [$e->getMessage()])];
1177 $send_folder_id = 0;
1179 $send_folder_id = $this->mailbox->getSentFolder();
1182 return $send_folder_id;
1222 $mailer->From($this->sender_factory->getSenderByUsrId($this->user_id));
1227 (
string) ($this->context_parameters[self::PROP_CONTEXT_SUBJECT_PREFIX] ??
'')
1231 $message .= $this->signature_service->user($this->user_id);
1233 $mailer->Body($message);
1244 foreach ($attachments as $attachment) {
1246 $this->mail_file_data->getAbsoluteAttachmentPoolPathByFilename($attachment),
1262 $this->table_mail_saved,
1264 'attachments' => [
'clob', serialize($attachments)],
1267 'user_id' => [
'integer', $this->user_id],
1278 if ($addresses !==
'') {
1279 $this->
logger->debug(sprintf(
1280 "Started parsing of recipient string: %s",
1285 $parser = $this->mail_address_parser_factory->getParser($addresses);
1286 $parsedAddresses = $parser->parse();
1288 if ($addresses !==
'') {
1289 $this->
logger->debug(sprintf(
1290 "Parsed addresses: %s",
1292 return (
string) $address;
1293 }, $parsedAddresses))
1297 return $parsedAddresses;
1303 if ($onlyExternalAddresses) {
1307 $this->usr_id_by_login_callable
1311 return count($addresses->value());
1315 string $toRecipients,
1316 string $ccRecipients,
1317 string $bccRecipients,
1318 bool $onlyExternalAddresses =
true 1332 $this->usr_id_by_login_callable
1336 return (
string) $address;
1337 }, $addresses->value());
1339 return implode(
',', $emailRecipients);
1350 $lang->loadLanguageModule(
'mail');
1353 $lang->txt(
'mail_auto_generated_info'),
1362 $senderFactory = $DIC->mail()->mime()->senderFactory();
1364 return $senderFactory->system()->getFromName();
1372 if (
null === $a_flag) {
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($usrId, $this->user_instances_by_id_map)) {
1417 $this->user_instances_by_id_map[$usrId] = $user;
1420 return $this->user_instances_by_id_map[$usrId];
1428 $this->user_instances_by_id_map = $userInstanceByIdMap;
1433 if (!isset($this->mail_options_by_usr_id_map[$usrId])) {
1434 $this->mail_options_by_usr_id_map[$usrId] =
new ilMailOptions($usrId);
1437 return $this->mail_options_by_usr_id_map[$usrId];
1445 $this->mail_options_by_usr_id_map = $mailOptionsByUsrIdMap;
1459 $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.
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
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'.
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 _getAutoGeneratedMessageString(?ilLanguage $lang=null)
static getTemplateContextById(string $a_id)
withContextParameters(array $parameters)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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 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.