ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilMail Class Reference
+ Inheritance diagram for ilMail:
+ Collaboration diagram for ilMail:

Public Member Functions

 __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,)
 
 autoresponder ()
 
 withContextId (string $context_id)
 
 withContextParameters (array $parameters)
 
 existsRecipient (string $new_recipient, string $existing_recipients)
 
 setSaveInSentbox (bool $save_in_sentbox)
 
 getSaveInSentbox ()
 
 getMailObjectReferenceId ()
 
 formatNamesForOutput (string $recipients)
 
 getPreviousMail (int $mail_id)
 
 getNextMail (int $mail_id)
 
 getMailsOfFolder (int $a_folder_id, array $filter=[])
 
 countMailsOfFolder (int $folder_id)
 
 deleteMailsOfFolder (int $folder_id)
 
 getMail (int $mail_id)
 
 markRead (array $mail_ids)
 
 markUnread (array $mail_ids)
 
 moveMailsToFolder (array $mail_ids, int $folder_id)
 
 deleteMails (array $mail_ids)
 
 getNewDraftId (int $folder_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=[])
 
 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=[])
 
 retrieveFromStage ()
 
 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'. More...
 
 sendMail (MailDeliveryData $mail_data)
 This method is used to finally send internal messages and external emails To use the mail system as a consumer, please use ilMail::enqueue. More...
 
 validateRecipients (string $to, string $cc, string $bcc)
 
 saveAttachments (array $attachments)
 
 appendInstallationSignature (?bool $a_flag=null)
 
 setUserInstanceById (array $user_instances_by_id_map)
 
 setMailOptionsByUserIdMap (array $mail_options_by_usr_id_map)
 
 formatLinebreakMessage (string $message)
 

Static Public Member Functions

static _getAutoGeneratedMessageString (?ilLanguage $lang=null)
 
static _getIliasMailerName ()
 
static _getInstallationSignature ()
 
static getSalutation (int $a_usr_id, ?ilLanguage $a_language=null)
 

Data Fields

const string ILIAS_HOST = 'ilias'
 
const string PROP_CONTEXT_SUBJECT_PREFIX = 'subject_prefix'
 
int $user_id
 

Protected Attributes

array $mail_data = []
 

Private Member Functions

 isSystemMail ()
 
 readMailObjectReferenceId ()
 
 fetchMailData (?array $row)
 
 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=[])
 
 replacePlaceholders (string $message, int $usr_id=0)
 
 replacePlaceholdersEmpty (string $message)
 
 distributeMail (MailDeliveryData $mail_data)
 
 sendMailWithReplacedPlaceholder (MailDeliveryData $mail_data, array $to_usr_ids)
 
 sendMailWithReplacedEmptyPlaceholder (MailDeliveryData $mail_data, array $recipients,)
 
 sendMailWithoutReplacedPlaceholder (MailDeliveryData $mail_data, array $to_usr_ids, array $cc_bcc_recipients)
 
 sendChanneledMails (MailDeliveryData $mail_data, array $recipients, string $message)
 
 delegateExternalEmails (string $subject, array $attachments, string $message, array $usr_id_to_external_email_addresses_map)
 
 getUserIds (array $recipients)
 
 checkMail (string $to, string $cc, string $bcc, string $subject)
 
 checkRecipients (string $recipients)
 
 getSubjectSentFolderId ()
 
 saveInSentbox (array $attachment, string $to, string $cc, string $bcc, string $subject, string $message)
 
 sendMimeMail (string $to, string $cc, string $bcc, string $subject, string $message, array $attachments)
 
 parseAddresses (string $addresses)
 Explode recipient string, allowed separators are ',' ';' ' '. More...
 
 getCountRecipient (string $recipients, bool $only_external_addresses=true)
 
 getCountRecipients (string $to_recipients, string $cc_recipients, string $bcc_recipients, bool $only_external_addresses=true)
 
 getEmailRecipients (string $recipients)
 
 getUserInstanceById (int $usr_id)
 
 getMailOptionsByUserId (int $usr_id)
 
 createRecipient (int $user_id)
 

Private Attributes

MailSignatureService $signature_service
 
string $table_mail
 
string $table_mail_saved
 
bool $save_in_sentbox
 
bool $append_installation_signature = false
 
bool $append_user_signature = false
 
string $context_id = null
 
array $context_parameters = []
 
array $mail_options_by_usr_id_map = []
 
array $user_instances_by_id_map = []
 
int $max_recipient_character_length = 998
 
readonly Conductor $legal_documents
 

Detailed Description

Definition at line 27 of file class.ilMail.php.

Constructor & Destructor Documentation

◆ __construct()

ilMail::__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 
)

Definition at line 53 of file class.ilMail.php.

References $DIC, $lng, ilObjUser\_lookupId(), ilLoggerFactory\getLogger(), ILIAS\Repository\int(), ILIAS\Repository\lng(), ILIAS\Repository\logger(), null, readMailObjectReferenceId(), and setSaveInSentbox().

74  {
75  global $DIC;
76  $this->logger = $logger ?? ilLoggerFactory::getLogger('mail');
77  $this->mail_address_type_factory = $mail_address_type_factory ?? new ilMailAddressTypeFactory(null, $logger);
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);
85 
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) {
92  }
93  $this->lng->loadLanguageModule('mail');
94  $this->table_mail = 'mail';
95  $this->table_mail_saved = 'mail_saved';
96  $this->setSaveInSentbox(false);
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();
101  }
static getLogger(string $a_component_id)
Get component logger.
MailSignatureService $signature_service
setSaveInSentbox(bool $save_in_sentbox)
readonly Conductor $legal_documents
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:26
global $lng
Definition: privfeed.php:31
readMailObjectReferenceId()
+ Here is the call graph for this function:

Member Function Documentation

◆ _getAutoGeneratedMessageString()

static ilMail::_getAutoGeneratedMessageString ( ?ilLanguage  $lang = null)
static

Definition at line 1342 of file class.ilMail.php.

References $DIC, $lang, ilUtil\_getHttpPath(), ilLanguageFactory\_getLanguage(), and ILIAS_VERSION_NUMERIC.

Referenced by ilSystemNotification\compose(), ilUserCronCheckAccounts\run(), ilMailSummaryNotification\send(), ilECSObjectSettings\sendNewContentNotification(), ilRemoteObjectBase\sendNewContentNotification(), and ilECSAppEventListener\sendNotification().

1342  : string
1343  {
1344  global $DIC;
1345 
1346  if (!($lang instanceof ilLanguage)) {
1348  }
1349 
1350  $lang->loadLanguageModule('mail');
1351 
1352  return sprintf(
1353  $lang->txt('mail_auto_generated_info'),
1354  $DIC->settings()->get('inst_name', 'ILIAS ' . ((int) ILIAS_VERSION_NUMERIC)),
1356  ) . "\n\n";
1357  }
const ILIAS_VERSION_NUMERIC
global $DIC
Definition: shib_login.php:26
static _getLanguage(string $a_lang_key='')
Get language object.
$lang
Definition: xapiexit.php:25
static _getHttpPath()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getIliasMailerName()

static ilMail::_getIliasMailerName ( )
static

Definition at line 1359 of file class.ilMail.php.

References $DIC.

Referenced by ilMailFolderGUI\confirmDeleteMails(), ilPDMailBlockGUI\getListItemForData(), ILIAS\Mail\Folder\MailFolderTableUI\getSender(), ilMailFolderGUI\printMail(), ilMailSummaryNotification\send(), and ilMailTest\testGetIliasMailerName().

1359  : string
1360  {
1361  global $DIC;
1362  $sender_factory = $DIC->mail()->mime()->senderFactory();
1363 
1364  return $sender_factory->system()->getFromName();
1365  }
global $DIC
Definition: shib_login.php:26
+ Here is the caller graph for this function:

◆ _getInstallationSignature()

◆ appendInstallationSignature()

ilMail::appendInstallationSignature ( ?bool  $a_flag = null)
Returns
self|bool

Definition at line 1370 of file class.ilMail.php.

References $append_installation_signature, and null.

Referenced by enqueue().

1371  {
1372  if ($a_flag === null) {
1374  }
1375 
1376  $this->append_installation_signature = $a_flag;
1377  return $this;
1378  }
bool $append_installation_signature
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ autoresponder()

ilMail::autoresponder ( )

Definition at line 103 of file class.ilMail.php.

104  {
105  return $this->auto_responder_service;
106  }

◆ checkMail()

ilMail::checkMail ( string  $to,
string  $cc,
string  $bcc,
string  $subject 
)
private
Returns
list<ilMailError>

Definition at line 866 of file class.ilMail.php.

References ilStr\strLen().

Referenced by enqueue().

866  : array
867  {
868  $errors = [];
869 
870  $checks = [
871  $subject => 'mail_add_subject',
872  $to => 'mail_add_recipient',
873  ];
874  foreach ($checks as $string => $error) {
875  if ($string === '') {
876  $errors[] = new ilMailError($error);
877  }
878  }
879 
880  if (ilStr::strLen($subject) > 255) {
881  // https://mantis.ilias.de/view.php?id=37881
882  $errors[] = new ilMailError('mail_subject_too_long');
883  }
884 
885  return $errors;
886  }
static strLen(string $a_string)
Definition: class.ilStr.php:60
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkRecipients()

ilMail::checkRecipients ( string  $recipients)
private
Returns
list<ilMailError>

Definition at line 891 of file class.ilMail.php.

References Vendor\Package\$e, and parseAddresses().

Referenced by validateRecipients().

891  : array
892  {
893  $errors = [];
894 
895  try {
896  $addresses = $this->parseAddresses($recipients);
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();
901  }
902  }
903  } catch (Exception $e) {
904  $position = strpos($e->getMessage(), ':');
905  throw new ilMailException(
906  ($position === false) ? $e->getMessage() : substr($e->getMessage(), $position + 2),
907  $e->getCode(),
908  $e
909  );
910  }
911 
912  return array_merge(...$errors);
913  }
parseAddresses(string $addresses)
Explode recipient string, allowed separators are &#39;,&#39; &#39;;&#39; &#39; &#39;.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ countMailsOfFolder()

ilMail::countMailsOfFolder ( int  $folder_id)

Definition at line 264 of file class.ilMail.php.

References $res.

264  : int
265  {
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]
270  );
271 
272  return $this->db->numRows($res);
273  }
$res
Definition: ltiservices.php:66

◆ createRecipient()

ilMail::createRecipient ( int  $user_id)
private

Definition at line 1453 of file class.ilMail.php.

References getMailOptionsByUserId(), and getUserInstanceById().

Referenced by distributeMail(), sendMailWithoutReplacedPlaceholder(), and sendMailWithReplacedPlaceholder().

1453  : Recipient
1454  {
1455  return new Recipient(
1456  $user_id,
1457  $this->getUserInstanceById($user_id),
1459  $this->legal_documents
1460  );
1461  }
int $user_id
getMailOptionsByUserId(int $usr_id)
getUserInstanceById(int $usr_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delegateExternalEmails()

ilMail::delegateExternalEmails ( string  $subject,
array  $attachments,
string  $message,
array  $usr_id_to_external_email_addresses_map 
)
private
Parameters
list<string>$attachments
array<int,string[]>$usr_id_to_external_email_addresses_map

Definition at line 779 of file class.ilMail.php.

References sendMimeMail(), and ilStr\strLen().

Referenced by sendChanneledMails().

784  : void {
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);
788 
789  $this->sendMimeMail(
790  implode(',', $first_addresses),
791  '',
792  '',
793  $subject,
794  $message,
795  $attachments
796  );
797  } elseif (count($usr_id_to_external_email_addresses_map) > 1) {
798  $flattened_email_addresses = iterator_to_array(new RecursiveIteratorIterator(new RecursiveArrayIterator(
799  $usr_id_to_external_email_addresses_map
800  )), false);
801 
802  $flattened_email_addresses = array_unique($flattened_email_addresses);
803 
804  // https://mantis.ilias.de/view.php?id=23981 and https://www.ietf.org/rfc/rfc2822.txt
805  $remaining_addresses = '';
806  foreach ($flattened_email_addresses as $email_address) {
807  $sep = '';
808  if ($remaining_addresses !== '') {
809  $sep = ',';
810  }
811 
812  $recipients_line_length = ilStr::strLen($remaining_addresses) +
813  ilStr::strLen($sep . $email_address);
814  if ($recipients_line_length >= $this->max_recipient_character_length) {
815  $this->sendMimeMail(
816  '',
817  '',
818  $remaining_addresses,
819  $subject,
820  $message,
821  $attachments
822  );
823 
824  $remaining_addresses = '';
825  $sep = '';
826  }
827 
828  $remaining_addresses .= ($sep . $email_address);
829  }
830 
831  if ($remaining_addresses !== '') {
832  $this->sendMimeMail(
833  '',
834  '',
835  $remaining_addresses,
836  $subject,
837  $message,
838  $attachments
839  );
840  }
841  }
842  }
sendMimeMail(string $to, string $cc, string $bcc, string $subject, string $message, array $attachments)
static strLen(string $a_string)
Definition: class.ilStr.php:60
$message
Definition: xapiexit.php:31
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteMails()

ilMail::deleteMails ( array  $mail_ids)
Parameters
list<int>$mailIds

Definition at line 375 of file class.ilMail.php.

References $id.

Referenced by deleteMailsOfFolder(), and sendMail().

375  : void
376  {
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]
383  );
384  $this->mail_file_data->deassignAttachmentFromDirectory($id);
385  }
386  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the caller graph for this function:

◆ deleteMailsOfFolder()

ilMail::deleteMailsOfFolder ( int  $folder_id)

Definition at line 275 of file class.ilMail.php.

References deleteMails(), and getMailsOfFolder().

275  : void
276  {
277  $mails = $this->getMailsOfFolder($folder_id);
278  foreach ($mails as $mail_data) {
279  $this->deleteMails([$mail_data['mail_id']]);
280  }
281  }
array $mail_data
getMailsOfFolder(int $a_folder_id, array $filter=[])
deleteMails(array $mail_ids)
+ Here is the call graph for this function:

◆ distributeMail()

ilMail::distributeMail ( MailDeliveryData  $mail_data)
private

Definition at line 591 of file class.ilMail.php.

References createRecipient(), MailDeliveryData\getBcc(), MailDeliveryData\getCc(), MailDeliveryData\getTo(), getUserIds(), MailDeliveryData\isUsePlaceholder(), ILIAS\Repository\logger(), sendMailWithoutReplacedPlaceholder(), sendMailWithReplacedEmptyPlaceholder(), and sendMailWithReplacedPlaceholder().

Referenced by sendMail().

591  : bool
592  {
593  $this->auto_responder_service->emptyAutoresponderData();
594  $to_usr_ids = $this->getUserIds([$mail_data->getTo()]);
595  $this->logger->debug(sprintf(
596  'Parsed TO user ids from given recipients for serial letter notification: %s',
597  implode(', ', $to_usr_ids)
598  ));
599 
600  $other_usr_ids = $this->getUserIds([$mail_data->getCc(), $mail_data->getBcc()]);
601  $cc_bcc_recipients = array_map(
602  $this->createRecipient(...),
603  $other_usr_ids
604  );
605  $this->logger->debug(sprintf(
606  'Parsed CC/BCC user ids from given recipients for serial letter notification: %s',
607  implode(', ', $other_usr_ids)
608  ));
609 
610  if ($mail_data->isUsePlaceholder()) {
611  $this->sendMailWithReplacedPlaceholder($mail_data, $to_usr_ids);
612  $this->sendMailWithReplacedEmptyPlaceholder($mail_data, $cc_bcc_recipients);
613  } else {
614  $this->sendMailWithoutReplacedPlaceholder($mail_data, $to_usr_ids, $cc_bcc_recipients);
615  }
616 
617  $this->auto_responder_service->disableAutoresponder();
618  $this->auto_responder_service->handleAutoresponderMails($this->user_id);
619 
620  return true;
621  }
sendMailWithReplacedPlaceholder(MailDeliveryData $mail_data, array $to_usr_ids)
sendMailWithReplacedEmptyPlaceholder(MailDeliveryData $mail_data, array $recipients,)
createRecipient(int $user_id)
sendMailWithoutReplacedPlaceholder(MailDeliveryData $mail_data, array $to_usr_ids, array $cc_bcc_recipients)
getUserIds(array $recipients)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ enqueue()

ilMail::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'.

A validation is executed before, errors are returned

Parameters
list<string>$a_attachment
Returns
list<ilMailError>

Definition at line 974 of file class.ilMail.php.

References $DIC, appendInstallationSignature(), checkMail(), ilContext\CONTEXT_CRON, getCountRecipients(), getSaveInSentbox(), ilContext\getType(), isSystemMail(), ILIAS\Repository\lng(), ILIAS\Repository\logger(), sendMail(), and validateRecipients().

982  : array {
983  global $DIC;
984 
985  $this->logger->info(
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)
992  );
993 
994  if ($a_attachment && !$this->mail_file_data->checkFilesExist($a_attachment)) {
995  return [new ilMailError('mail_attachment_file_not_exist', [implode(', ', $a_attachment)])];
996  }
997 
998  $errors = $this->checkMail($a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_m_subject);
999  if ($errors !== []) {
1000  return $errors;
1001  }
1002 
1003  $errors = $this->validateRecipients($a_rcp_to, $a_rcp_cc, $a_rcp_bcc);
1004  if ($errors !== []) {
1005  return $errors;
1006  }
1007 
1008  $rcp_to = $a_rcp_to;
1009  $rcp_cc = $a_rcp_cc;
1010  $rcp_bcc = $a_rcp_bcc;
1011 
1012  $number_of_external_addresses = $this->getCountRecipients($rcp_to, $rcp_cc, $rcp_bcc);
1013  if (
1014  $number_of_external_addresses > 0 &&
1015  !$this->isSystemMail() &&
1016  !$DIC->rbac()->system()->checkAccessOfUser($this->user_id, 'smtp_mail', $this->mail_obj_ref_id)
1017  ) {
1018  return [new ilMailError('mail_no_permissions_write_smtp')];
1019  }
1020 
1021  if ($this->appendInstallationSignature()) {
1022  $a_m_message .= self::_getInstallationSignature();
1023  }
1024 
1027  $rcp_to,
1028  $rcp_cc,
1029  $rcp_bcc,
1030  $a_m_subject,
1031  $a_m_message,
1032  $a_attachment,
1033  $a_use_placeholders
1034  );
1035  return $this->sendMail($mail_data);
1036  }
1037 
1038  $task_factory = $DIC->backgroundTasks()->taskFactory();
1039  $task_manager = $DIC->backgroundTasks()->taskManager();
1040 
1041  $bucket = new BasicBucket();
1042  $bucket->setUserId($this->user_id);
1043 
1044  $task = $task_factory->createTask(ilMailDeliveryJob::class, [
1045  $this->user_id,
1046  $rcp_to,
1047  $rcp_cc,
1048  $rcp_bcc,
1049  $a_m_subject,
1050  $a_m_message,
1051  serialize($a_attachment),
1052  $a_use_placeholders,
1053  $this->getSaveInSentbox(),
1054  (string) $this->context_id,
1055  serialize(array_merge(
1056  $this->context_parameters,
1057  [
1058  'auto_responder' => $this->auto_responder_service->isAutoresponderEnabled()
1059  ]
1060  ))
1061  ]);
1062  $interaction = $task_factory->createTask(ilMailDeliveryJobUserInteraction::class, [
1063  $task,
1064  $this->user_id,
1065  ]);
1066 
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));
1070 
1071  $this->logger->info('Delegated delivery to background task');
1072  $task_manager->run($bucket);
1073 
1074  return [];
1075  }
getCountRecipients(string $to_recipients, string $cc_recipients, string $bcc_recipients, bool $only_external_addresses=true)
array $mail_data
checkMail(string $to, string $cc, string $bcc, string $subject)
const CONTEXT_CRON
appendInstallationSignature(?bool $a_flag=null)
isSystemMail()
global $DIC
Definition: shib_login.php:26
getSaveInSentbox()
validateRecipients(string $to, string $cc, string $bcc)
sendMail(MailDeliveryData $mail_data)
This method is used to finally send internal messages and external emails To use the mail system as a...
static getType()
Get context type.
+ Here is the call graph for this function:

◆ existsRecipient()

ilMail::existsRecipient ( string  $new_recipient,
string  $existing_recipients 
)

Definition at line 131 of file class.ilMail.php.

References parseAddresses().

131  : bool
132  {
133  $new_addresses = new ilMailAddressListImpl($this->parseAddresses($new_recipient));
134  $addresses = new ilMailAddressListImpl($this->parseAddresses($existing_recipients));
135  $list = new ilMailDiffAddressList($new_addresses, $addresses);
136 
137  $diffed_addresses = $list->value();
138 
139  return $diffed_addresses === [];
140  }
parseAddresses(string $addresses)
Explode recipient string, allowed separators are &#39;,&#39; &#39;;&#39; &#39; &#39;.
+ Here is the call graph for this function:

◆ fetchMailData()

ilMail::fetchMailData ( ?array  $row)
private

Definition at line 388 of file class.ilMail.php.

References ILIAS\Repository\int(), and null.

Referenced by getMail(), getMailsOfFolder(), getNextMail(), getPreviousMail(), and retrieveFromStage().

388  : ?array
389  {
390  if (!is_array($row) || empty($row)) {
391  return null;
392  }
393 
394  if (isset($row['attachments'])) {
395  $unserialized = unserialize(stripslashes((string) $row['attachments']), ['allowed_classes' => false]);
396  $row['attachments'] = is_array($unserialized) ? $unserialized : [];
397  } else {
398  $row['attachments'] = [];
399  }
400 
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 ?? []);
404  } else {
405  $row['tpl_ctx_params'] = [];
406  }
407 
408  if (isset($row['mail_id'])) {
409  $row['mail_id'] = (int) $row['mail_id'];
410  }
411 
412  if (isset($row['user_id'])) {
413  $row['user_id'] = (int) $row['user_id'];
414  }
415 
416  if (isset($row['folder_id'])) {
417  $row['folder_id'] = (int) $row['folder_id'];
418  }
419 
420  if (isset($row['sender_id'])) {
421  $row['sender_id'] = (int) $row['sender_id'];
422  }
423 
424  if (isset($row['use_placeholders'])) {
425  $row['use_placeholders'] = (bool) $row['use_placeholders'];
426  }
427 
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] = '';
432  }
433  }
434 
435  return $row;
436  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ formatLinebreakMessage()

ilMail::formatLinebreakMessage ( string  $message)

Definition at line 1448 of file class.ilMail.php.

References $message.

1448  : string
1449  {
1450  return $message;
1451  }
$message
Definition: xapiexit.php:31

◆ formatNamesForOutput()

ilMail::formatNamesForOutput ( string  $recipients)

Definition at line 162 of file class.ilMail.php.

References ilObjUser\_lookupId(), ilObjUser\_lookupPref(), getUserInstanceById(), and ILIAS\Repository\lng().

162  : string
163  {
164  $recipients = trim($recipients);
165  if ($recipients === '') {
166  return $this->lng->txt('not_available');
167  }
168 
169  $names = [];
170 
171  $recipients = array_filter(array_map('trim', explode(',', $recipients)));
172  foreach ($recipients as $recipient) {
173  $usr_id = ilObjUser::_lookupId($recipient);
174  if (is_int($usr_id) && $usr_id > 0) {
175  $pp = ilObjUser::_lookupPref($usr_id, 'public_profile');
176  if ($pp === 'g' || ($pp === 'y' && !$this->actor->isAnonymous())) {
177  $user = $this->getUserInstanceById($usr_id);
178  if ($user) {
179  $names[] = $user->getFullname() . ' [' . $recipient . ']';
180  continue;
181  }
182  }
183  }
184 
185  $names[] = $recipient;
186  }
187 
188  return implode(', ', $names);
189  }
static _lookupId($a_user_str)
static _lookupPref(int $a_usr_id, string $a_keyword)
getUserInstanceById(int $usr_id)
+ Here is the call graph for this function:

◆ getCountRecipient()

ilMail::getCountRecipient ( string  $recipients,
bool  $only_external_addresses = true 
)
private

Definition at line 1302 of file class.ilMail.php.

References parseAddresses().

Referenced by getCountRecipients().

1302  : int
1303  {
1304  $addresses = new ilMailAddressListImpl($this->parseAddresses($recipients));
1305  if ($only_external_addresses) {
1306  $addresses = new ilMailOnlyExternalAddressList(
1307  $addresses,
1308  self::ILIAS_HOST,
1309  $this->usr_id_by_login_callable
1310  );
1311  }
1312 
1313  return count($addresses->value());
1314  }
parseAddresses(string $addresses)
Explode recipient string, allowed separators are &#39;,&#39; &#39;;&#39; &#39; &#39;.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCountRecipients()

ilMail::getCountRecipients ( string  $to_recipients,
string  $cc_recipients,
string  $bcc_recipients,
bool  $only_external_addresses = true 
)
private

Definition at line 1316 of file class.ilMail.php.

References getCountRecipient().

Referenced by enqueue(), and sendMail().

1321  : int {
1322  return (
1323  $this->getCountRecipient($to_recipients, $only_external_addresses) +
1324  $this->getCountRecipient($cc_recipients, $only_external_addresses) +
1325  $this->getCountRecipient($bcc_recipients, $only_external_addresses)
1326  );
1327  }
getCountRecipient(string $recipients, bool $only_external_addresses=true)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getEmailRecipients()

ilMail::getEmailRecipients ( string  $recipients)
private

Definition at line 1329 of file class.ilMail.php.

References parseAddresses().

Referenced by sendMail().

1329  : string
1330  {
1331  $addresses = new ilMailOnlyExternalAddressList(
1332  new ilMailAddressListImpl($this->parseAddresses($recipients)),
1333  self::ILIAS_HOST,
1334  $this->usr_id_by_login_callable
1335  );
1336 
1337  $email_recipients = array_map(static fn(ilMailAddress $address): string => (string) $address, $addresses->value());
1338 
1339  return implode(',', $email_recipients);
1340  }
parseAddresses(string $addresses)
Explode recipient string, allowed separators are &#39;,&#39; &#39;;&#39; &#39; &#39;.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMail()

ilMail::getMail ( int  $mail_id)

Definition at line 283 of file class.ilMail.php.

References $mail_data, $res, and fetchMailData().

283  : ?array
284  {
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]
289  );
290 
291  $this->mail_data = $this->fetchMailData($this->db->fetchAssoc($res));
292 
293  return $this->mail_data;
294  }
$res
Definition: ltiservices.php:66
array $mail_data
fetchMailData(?array $row)
+ Here is the call graph for this function:

◆ getMailObjectReferenceId()

ilMail::getMailObjectReferenceId ( )

Definition at line 157 of file class.ilMail.php.

157  : int
158  {
159  return $this->mail_obj_ref_id;
160  }

◆ getMailOptionsByUserId()

ilMail::getMailOptionsByUserId ( int  $usr_id)
private

Definition at line 1431 of file class.ilMail.php.

Referenced by createRecipient(), and sendChanneledMails().

1431  : ilMailOptions
1432  {
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);
1435  }
1436 
1437  return $this->mail_options_by_usr_id_map[$usr_id];
1438  }
+ Here is the caller graph for this function:

◆ getMailsOfFolder()

ilMail::getMailsOfFolder ( int  $a_folder_id,
array  $filter = [] 
)

Definition at line 233 of file class.ilMail.php.

References $res, and fetchMailData().

Referenced by deleteMailsOfFolder(), and ilPDMailBlockGUI\getMails().

233  : array
234  {
235  $mails = [];
236 
237  $query =
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))';
244 
245  if (isset($filter['status']) && $filter['status'] !== '') {
246  $query .= ' AND m_status = ' . $this->db->quote($filter['status'], 'text');
247  }
248 
249  $query .= ' ORDER BY send_time DESC';
250 
251  $res = $this->db->queryF(
252  $query,
253  ['integer', 'integer'],
254  [$this->user_id, $a_folder_id]
255  );
256 
257  while ($row = $this->db->fetchAssoc($res)) {
258  $mails[] = $this->fetchMailData($row);
259  }
260 
261  return array_filter($mails);
262  }
$res
Definition: ltiservices.php:66
fetchMailData(?array $row)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNewDraftId()

ilMail::getNewDraftId ( int  $folder_id)

Definition at line 438 of file class.ilMail.php.

438  : int
439  {
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],
446  ]);
447 
448  return $next_id;
449  }

◆ getNextMail()

ilMail::getNextMail ( int  $mail_id)

Definition at line 212 of file class.ilMail.php.

References $mail_data, $res, and fetchMailData().

212  : ?array
213  {
214  $this->db->setLimit(1, 0);
215 
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',
221  ]);
222  $res = $this->db->queryF(
223  $query,
224  ['integer', 'integer'],
225  [$this->user_id, $mail_id]
226  );
227 
228  $this->mail_data = $this->fetchMailData($this->db->fetchAssoc($res));
229 
230  return $this->mail_data;
231  }
$res
Definition: ltiservices.php:66
array $mail_data
fetchMailData(?array $row)
+ Here is the call graph for this function:

◆ getPreviousMail()

ilMail::getPreviousMail ( int  $mail_id)

Definition at line 191 of file class.ilMail.php.

References $mail_data, $res, and fetchMailData().

191  : ?array
192  {
193  $this->db->setLimit(1, 0);
194 
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',
200  ]);
201  $res = $this->db->queryF(
202  $query,
203  ['integer', 'integer'],
204  [$this->user_id, $mail_id]
205  );
206 
207  $this->mail_data = $this->fetchMailData($this->db->fetchAssoc($res));
208 
209  return $this->mail_data;
210  }
$res
Definition: ltiservices.php:66
array $mail_data
fetchMailData(?array $row)
+ Here is the call graph for this function:

◆ getSalutation()

static ilMail::getSalutation ( int  $a_usr_id,
?ilLanguage  $a_language = null 
)
static

Definition at line 1386 of file class.ilMail.php.

References $DIC, $lang, ilObjUser\_lookupGender(), and ilObjUser\_lookupName().

Referenced by ilTestManScoringParticipantNotification\buildBody(), ilSystemNotification\compose(), ilForumMailNotification\createMail(), ilForumMailEventNotificationSender\createMailBodyText(), ilChatroom\getSessions(), ilUserCronCheckAccounts\run(), ilRegistrationMailNotification\send(), ilMailSummaryNotification\send(), ILIAS\Portfolio\Notification\SharedNotification\send(), ilLMMailNotification\send(), ILIAS\Mail\Cron\ExpiredOrOrphanedMails\MailNotification\send(), ilDataCollectionMailNotification\send(), ilBuddySystemNotification\send(), ilSessionMembershipMailNotification\send(), ilLearningSequenceMembershipMailNotification\send(), ilIndividualAssessmentPrimitiveInternalNotificator\send(), ilCalendarMailNotification\send(), ilExerciseMailNotification\send(), ilCourseMembershipMailNotification\send(), ilGroupMembershipMailNotification\send(), ilTestMailNotification\sendAdvancedNotification(), ilExerciseMailNotification\sendExerciseNotification(), ilTestMailNotification\sendSimpleNotification(), and ilObjSurveyGUI\sendUserResultsMail().

1386  : string
1387  {
1388  global $DIC;
1389 
1390  $lang = ($a_language instanceof ilLanguage) ? $a_language : $DIC->language();
1391  $lang->loadLanguageModule('mail');
1392 
1393  $gender = ilObjUser::_lookupGender($a_usr_id);
1394  $gender = $gender ?: 'n';
1395  $name = ilObjUser::_lookupName($a_usr_id);
1396 
1397  if ($name['firstname'] === '') {
1398  return $lang->txt('mail_salutation_anonymous') . ',';
1399  }
1400 
1401  return
1402  $lang->txt('mail_salutation_' . $gender) . ' ' .
1403  ($name['title'] ? $name['title'] . ' ' : '') .
1404  ($name['firstname'] ? $name['firstname'] . ' ' : '') .
1405  $name['lastname'] . ',';
1406  }
static _lookupName(int $a_user_id)
lookup user name
static _lookupGender(int $a_user_id)
global $DIC
Definition: shib_login.php:26
$lang
Definition: xapiexit.php:25
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSaveInSentbox()

ilMail::getSaveInSentbox ( )

Definition at line 147 of file class.ilMail.php.

References $save_in_sentbox.

Referenced by enqueue(), and sendMail().

147  : bool
148  {
149  return $this->save_in_sentbox;
150  }
bool $save_in_sentbox
+ Here is the caller graph for this function:

◆ getSubjectSentFolderId()

ilMail::getSubjectSentFolderId ( )
private

Definition at line 1179 of file class.ilMail.php.

References isSystemMail().

Referenced by saveInSentbox(), and sendInternalMail().

1179  : int
1180  {
1181  $send_folder_id = 0;
1182  if (!$this->isSystemMail()) {
1183  $send_folder_id = $this->mailbox->getSentFolder();
1184  }
1185 
1186  return $send_folder_id;
1187  }
isSystemMail()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUserIds()

ilMail::getUserIds ( array  $recipients)
private
Parameters
list<string>$recipients
Returns
list<int>

Definition at line 848 of file class.ilMail.php.

References parseAddresses().

Referenced by distributeMail().

848  : array
849  {
850  $parsed_usr_ids = [];
851 
852  $joined_recipients = implode(',', array_filter(array_map('trim', $recipients)));
853 
854  $addresses = $this->parseAddresses($joined_recipients);
855  foreach ($addresses as $address) {
856  $address_type = $this->mail_address_type_factory->getByPrefix($address);
857  $parsed_usr_ids[] = $address_type->resolve();
858  }
859 
860  return array_unique(array_merge(...$parsed_usr_ids));
861  }
parseAddresses(string $addresses)
Explode recipient string, allowed separators are &#39;,&#39; &#39;;&#39; &#39; &#39;.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUserInstanceById()

ilMail::getUserInstanceById ( int  $usr_id)
private

Definition at line 1408 of file class.ilMail.php.

References null.

Referenced by createRecipient(), formatNamesForOutput(), and replacePlaceholders().

1408  : ?ilObjUser
1409  {
1410  if (!array_key_exists($usr_id, $this->user_instances_by_id_map)) {
1411  try {
1412  $user = new ilObjUser($usr_id);
1413  } catch (Exception) {
1414  $user = null;
1415  }
1416 
1417  $this->user_instances_by_id_map[$usr_id] = $user;
1418  }
1419 
1420  return $this->user_instances_by_id_map[$usr_id];
1421  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ isSystemMail()

ilMail::isSystemMail ( )
private

Definition at line 126 of file class.ilMail.php.

References ANONYMOUS_USER_ID.

Referenced by enqueue(), getSubjectSentFolderId(), sendChanneledMails(), sendMail(), and sendMimeMail().

126  : bool
127  {
128  return $this->user_id === ANONYMOUS_USER_ID;
129  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
+ Here is the caller graph for this function:

◆ markRead()

ilMail::markRead ( array  $mail_ids)
Parameters
list<int>$mail_ids

Definition at line 299 of file class.ilMail.php.

References $user_id.

299  : void
300  {
301  $values = [];
302  $types = [];
303 
304  $query = "UPDATE $this->table_mail SET m_status = %s WHERE user_id = %s ";
305  $types[] = 'text';
306  $types[] = 'integer';
307  $values[] = 'read';
308  $values[] = $this->user_id;
309 
310  if ($mail_ids !== []) {
311  $query .= ' AND ' . $this->db->in('mail_id', $mail_ids, false, 'integer');
312  }
313 
314  $this->db->manipulateF($query, $types, $values);
315  }
int $user_id

◆ markUnread()

ilMail::markUnread ( array  $mail_ids)
Parameters
list<int>$mail_ids

Definition at line 320 of file class.ilMail.php.

References $user_id.

320  : void
321  {
322  $values = [];
323  $types = [];
324 
325  $query = "UPDATE $this->table_mail SET m_status = %s WHERE user_id = %s ";
326  $types[] = 'text';
327  $types[] = 'integer';
328  $values[] = 'unread';
329  $values[] = $this->user_id;
330 
331  if ($mail_ids !== []) {
332  $query .= ' AND ' . $this->db->in('mail_id', $mail_ids, false, 'integer');
333  }
334 
335  $this->db->manipulateF($query, $types, $values);
336  }
int $user_id

◆ moveMailsToFolder()

ilMail::moveMailsToFolder ( array  $mail_ids,
int  $folder_id 
)
Parameters
list<int>$mail_ids

Definition at line 341 of file class.ilMail.php.

References $user_id.

341  : bool
342  {
343  $values = [];
344  $types = [];
345 
346  $mail_ids = array_filter(array_map(intval(...), $mail_ids));
347 
348  if ([] === $mail_ids) {
349  return false;
350  }
351 
352  $query =
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;
362  $values[] = $this->user_id;
363  $values[] = $this->user_id;
364 
365  $query .= ' AND ' . $this->db->in('mail_id', $mail_ids, false, 'integer');
366 
367  $affected_rows = $this->db->manipulateF($query, $types, $values);
368 
369  return $affected_rows > 0;
370  }
int $user_id

◆ parseAddresses()

ilMail::parseAddresses ( string  $addresses)
private

Explode recipient string, allowed separators are ',' ';' ' '.

Returns
list<ilMailAddress>

Definition at line 1280 of file class.ilMail.php.

References ILIAS\Repository\logger().

Referenced by checkRecipients(), existsRecipient(), getCountRecipient(), getEmailRecipients(), and getUserIds().

1280  : array
1281  {
1282  if ($addresses !== '') {
1283  $this->logger->debug(sprintf(
1284  'Started parsing of recipient string: %s',
1285  $addresses
1286  ));
1287  }
1288 
1289  $parser = $this->mail_address_parser_factory->getParser($addresses);
1290  $parsed_addresses = $parser->parse();
1291 
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))
1296  ));
1297  }
1298 
1299  return $parsed_addresses;
1300  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ persistToStage()

ilMail::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 = [] 
)
Parameters
list<string>$a_attachments

Definition at line 918 of file class.ilMail.php.

References retrieveFromStage().

Referenced by retrieveFromStage().

929  : bool {
930  $this->db->replace(
931  $this->table_mail_saved,
932  [
933  'user_id' => ['integer', $this->user_id],
934  ],
935  [
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)],
945  ]
946  );
947 
948  $this->retrieveFromStage();
949 
950  return true;
951  }
retrieveFromStage()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readMailObjectReferenceId()

ilMail::readMailObjectReferenceId ( )
private

Definition at line 152 of file class.ilMail.php.

References ilMailGlobalServices\getMailObjectRefId().

Referenced by __construct().

152  : void
153  {
154  $this->mail_obj_ref_id = ilMailGlobalServices::getMailObjectRefId();
155  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ replacePlaceholders()

ilMail::replacePlaceholders ( string  $message,
int  $usr_id = 0 
)
private

Definition at line 556 of file class.ilMail.php.

References $context, Vendor\Package\$e, $message, ilMailTemplateContextService\getTemplateContextById(), getUserInstanceById(), ILIAS\Repository\logger(), and null.

Referenced by sendInternalMail(), sendMail(), and sendMailWithReplacedPlaceholder().

559  : string {
560  try {
561  if ($this->context_id) {
563  } else {
565  }
566 
567  $user = $usr_id > 0 ? $this->getUserInstanceById($usr_id) : null;
568  $message = $this->placeholder_resolver->resolve(
569  $context,
570  $message,
571  $user,
572  $this->context_parameters
573  );
574  } catch (Exception $e) {
575  $this->logger->error(sprintf(
576  '%s has been called with invalid context: %s / %s',
577  __METHOD__,
578  $e->getMessage(),
579  $e->getTraceAsString()
580  ));
581  }
582 
583  return $message;
584  }
$context
Definition: webdav.php:31
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$message
Definition: xapiexit.php:31
getUserInstanceById(int $usr_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ replacePlaceholdersEmpty()

ilMail::replacePlaceholdersEmpty ( string  $message)
private

Definition at line 586 of file class.ilMail.php.

Referenced by sendMailWithReplacedEmptyPlaceholder().

586  : string
587  {
588  return $this->placeholder_to_empty_resolver->resolve($message);
589  }
$message
Definition: xapiexit.php:31
+ Here is the caller graph for this function:

◆ retrieveFromStage()

ilMail::retrieveFromStage ( )

Definition at line 953 of file class.ilMail.php.

References $mail_data, $res, fetchMailData(), and persistToStage().

Referenced by ilObjUserFolderGUI\mailObject(), and persistToStage().

953  : array
954  {
955  $res = $this->db->queryF(
956  "SELECT * FROM $this->table_mail_saved WHERE user_id = %s",
957  ['integer'],
958  [$this->user_id]
959  );
960 
961  $this->mail_data = $this->fetchMailData($this->db->fetchAssoc($res));
962  if (!is_array($this->mail_data)) {
963  $this->persistToStage($this->user_id, [], '', '', '', '', '', false);
964  }
965 
966  return $this->mail_data;
967  }
$res
Definition: ltiservices.php:66
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=[])
array $mail_data
fetchMailData(?array $row)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveAttachments()

ilMail::saveAttachments ( array  $attachments)
Parameters
list<string>$attachments

Definition at line 1263 of file class.ilMail.php.

1263  : void
1264  {
1265  $this->db->update(
1266  $this->table_mail_saved,
1267  [
1268  'attachments' => ['clob', serialize($attachments)],
1269  ],
1270  [
1271  'user_id' => ['integer', $this->user_id],
1272  ]
1273  );
1274  }

◆ saveInSentbox()

ilMail::saveInSentbox ( array  $attachment,
string  $to,
string  $cc,
string  $bcc,
string  $subject,
string  $message 
)
private
Parameters
list<string>$attachment

Definition at line 1192 of file class.ilMail.php.

References getSubjectSentFolderId(), and sendInternalMail().

Referenced by sendMail().

1199  : int {
1200  return $this->sendInternalMail(
1201  $this->getSubjectSentFolderId(),
1202  $this->user_id,
1203  $attachment,
1204  $to,
1205  $cc,
1206  $bcc,
1207  'read',
1208  $subject,
1209  $message,
1210  $this->user_id
1211  );
1212  }
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=[])
$message
Definition: xapiexit.php:31
getSubjectSentFolderId()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendChanneledMails()

ilMail::sendChanneledMails ( MailDeliveryData  $mail_data,
array  $recipients,
string  $message 
)
private
Parameters
list<Recipient>$recipients

Definition at line 679 of file class.ilMail.php.

References $message, delegateExternalEmails(), MailDeliveryData\getAttachments(), MailDeliveryData\getCc(), MailDeliveryData\getInternalMailId(), getMailOptionsByUserId(), MailDeliveryData\getSubject(), MailDeliveryData\getTo(), isSystemMail(), ILIAS\Repository\logger(), and sendInternalMail().

Referenced by sendMailWithoutReplacedPlaceholder(), sendMailWithReplacedEmptyPlaceholder(), and sendMailWithReplacedPlaceholder().

683  : void {
684  $usr_id_to_external_email_addresses_map = [];
685 
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()
691  ));
692  continue;
693  }
694 
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()
701  ));
702  continue;
703  }
704 
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;
709 
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)
715  ));
716  continue;
717  }
718 
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)
725  ));
726  } else {
727  $this->logger->debug(sprintf(
728  'Recipient with id %s does not want to receive external emails',
729  $recipient->getUserId()
730  ));
731  }
732  } else {
733  $this->logger->debug(sprintf(
734  'Recipient with id %s is inactive or expired and will not receive external emails',
735  $recipient->getUserId()
736  ));
737  }
738 
739  $mbox = clone $this->mailbox;
740  $mbox->setUsrId($recipient->getUserId());
741  $recipient_inbox_id = $mbox->getInboxFolder();
742 
743  $internal_mail_id = $this->sendInternalMail(
744  $recipient_inbox_id,
745  $this->user_id,
746  $mail_data->getAttachments(),
747  $mail_data->getTo(),
748  $mail_data->getCc(),
749  '',
750  'unread',
751  $mail_data->getSubject(),
752  $message,
753  $recipient->getUserId()
754  );
755 
756  $this->auto_responder_service->enqueueAutoresponderIfEnabled(
757  $recipient->getUserId(),
758  $recipient->getMailOptions(),
759  $this->getMailOptionsByUserId($this->user_id),
760  );
761 
762  if ($mail_data->getAttachments() !== []) {
763  $this->mail_file_data->assignAttachmentsToDirectory($internal_mail_id, $mail_data->getInternalMailId());
764  }
765  }
766 
767  $this->delegateExternalEmails(
768  $mail_data->getSubject(),
769  $mail_data->getAttachments(),
770  $message,
771  $usr_id_to_external_email_addresses_map
772  );
773  }
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)
isSystemMail()
$message
Definition: xapiexit.php:31
delegateExternalEmails(string $subject, array $attachments, string $message, array $usr_id_to_external_email_addresses_map)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendInternalMail()

ilMail::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 = [] 
)
private

Definition at line 491 of file class.ilMail.php.

References $user_id, getSubjectSentFolderId(), and replacePlaceholders().

Referenced by saveInSentbox(), and sendChanneledMails().

505  : int {
506  $usr_id = $usr_id ?: $this->user_id;
507 
508  if ($use_placeholders) {
509  $message = $this->replacePlaceholders($message, $usr_id);
510  }
511  $message = str_ireplace(['<br />', '<br>', '<br/>'], "\n", $message);
512 
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)],
529  ]);
530 
531  $sender_equals_reveiver = $usr_id === $this->mailbox->getUsrId();
532  $is_sent_folder_of_sender = false;
533  if ($sender_equals_reveiver) {
534  $current_folder_id = $this->getSubjectSentFolderId();
535  $is_sent_folder_of_sender = $folder_id === $current_folder_id;
536  }
537 
538  $raise_event = !$sender_equals_reveiver || !$is_sent_folder_of_sender;
539 
540  if ($raise_event) {
541  $this->event_handler->raise('components/ILIAS/Mail', 'sentInternalMail', [
542  'id' => $next_id,
543  'subject' => $subject,
544  'body' => $message,
545  'from_usr_id' => $sender_usr_id,
546  'to_usr_id' => $usr_id,
547  'rcp_to' => $to,
548  'rcp_cc' => $cc,
549  'rcp_bcc' => $bcc,
550  ]);
551  }
552 
553  return $next_id;
554  }
replacePlaceholders(string $message, int $usr_id=0)
int $user_id
$message
Definition: xapiexit.php:31
getSubjectSentFolderId()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendMail()

ilMail::sendMail ( MailDeliveryData  $mail_data)

This method is used to finally send internal messages and external emails To use the mail system as a consumer, please use ilMail::enqueue.

Parameters
list<string>$attachments
Returns
list<ilMailError>
See also
ilMail::enqueue()

Definition at line 1085 of file class.ilMail.php.

References deleteMails(), distributeMail(), MailDeliveryData\getAttachments(), MailDeliveryData\getBcc(), MailDeliveryData\getCc(), getCountRecipients(), getEmailRecipients(), MailDeliveryData\getMessage(), getSaveInSentbox(), MailDeliveryData\getSubject(), MailDeliveryData\getTo(), isSystemMail(), ILIAS\Repository\logger(), replacePlaceholders(), saveInSentbox(), sendMimeMail(), and MailDeliveryData\withInternalMailId().

Referenced by enqueue().

1087  : array {
1088  $internal_message_id = $this->saveInSentbox(
1089  $mail_data->getAttachments(),
1090  $mail_data->getTo(),
1091  $mail_data->getCc(),
1092  $mail_data->getBcc(),
1093  $mail_data->getSubject(),
1094  $mail_data->getMessage()
1095  );
1096  $mail_data = $mail_data->withInternalMailId($internal_message_id);
1097 
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());
1101  }
1102 
1103  $num_external_email_addresses = $this->getCountRecipients(
1104  $mail_data->getTo(),
1105  $mail_data->getCc(),
1106  $mail_data->getBcc()
1107  );
1108 
1109  if ($num_external_email_addresses > 0) {
1110  $external_mail_recipients_to = $this->getEmailRecipients($mail_data->getTo());
1111  $external_mail_recipients_cc = $this->getEmailRecipients($mail_data->getCc());
1112  $external_eail_recipients_bcc = $this->getEmailRecipients($mail_data->getBcc());
1113 
1114  $this->logger->debug(
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()
1120  );
1121 
1122  $this->sendMimeMail(
1123  $external_mail_recipients_to,
1124  $external_mail_recipients_cc,
1125  $external_eail_recipients_bcc,
1126  $mail_data->getSubject(),
1127  $mail_data->isUsePlaceholder() ?
1128  $this->replacePlaceholders($mail_data->getMessage(), 0) :
1129  $mail_data->getMessage(),
1130  $mail_data->getAttachments()
1131  );
1132  } else {
1133  $this->logger->debug('No external email addresses given in recipient string');
1134  }
1135 
1136  $errors = [];
1137  if (!$this->distributeMail($mail_data)) {
1138  $errors['mail_send_error'] = new ilMailError('mail_send_error');
1139  }
1140 
1141  if (!$this->getSaveInSentbox()) {
1142  $this->deleteMails([$internal_message_id]);
1143  }
1144 
1145  if ($this->isSystemMail()) {
1146  $random = new Random\Randomizer();
1147  if ($random->getInt(0, 50) === 2) {
1149  $this->logger,
1150  $this->mail_file_data
1151  ))->run();
1152  }
1153  }
1154 
1155  return array_values($errors);
1156  }
replacePlaceholders(string $message, int $usr_id=0)
getEmailRecipients(string $recipients)
getCountRecipients(string $to_recipients, string $cc_recipients, string $bcc_recipients, bool $only_external_addresses=true)
sendMimeMail(string $to, string $cc, string $bcc, string $subject, string $message, array $attachments)
saveInSentbox(array $attachment, string $to, string $cc, string $bcc, string $subject, string $message)
isSystemMail()
distributeMail(MailDeliveryData $mail_data)
getSaveInSentbox()
deleteMails(array $mail_ids)
withInternalMailId(int $internal_mail_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendMailWithoutReplacedPlaceholder()

ilMail::sendMailWithoutReplacedPlaceholder ( MailDeliveryData  $mail_data,
array  $to_usr_ids,
array  $cc_bcc_recipients 
)
private
Parameters
list<int>$to_usr_ids
list<Recipient>$cc_bcc_recipients

Definition at line 659 of file class.ilMail.php.

References createRecipient(), MailDeliveryData\getMessage(), and sendChanneledMails().

Referenced by distributeMail().

663  : void {
664  $to_recipients = array_map(
665  $this->createRecipient(...),
666  $to_usr_ids
667  );
668 
669  $this->sendChanneledMails(
670  $mail_data,
671  array_merge($to_recipients, $cc_bcc_recipients),
672  $mail_data->getMessage()
673  );
674  }
sendChanneledMails(MailDeliveryData $mail_data, array $recipients, string $message)
createRecipient(int $user_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendMailWithReplacedEmptyPlaceholder()

ilMail::sendMailWithReplacedEmptyPlaceholder ( MailDeliveryData  $mail_data,
array  $recipients 
)
private
Parameters
list<Recipient>$recipients

Definition at line 644 of file class.ilMail.php.

References MailDeliveryData\getMessage(), replacePlaceholdersEmpty(), and sendChanneledMails().

Referenced by distributeMail().

647  : void {
648  $this->sendChanneledMails(
649  $mail_data,
650  $recipients,
651  $this->replacePlaceholdersEmpty($mail_data->getMessage()),
652  );
653  }
sendChanneledMails(MailDeliveryData $mail_data, array $recipients, string $message)
replacePlaceholdersEmpty(string $message)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendMailWithReplacedPlaceholder()

ilMail::sendMailWithReplacedPlaceholder ( MailDeliveryData  $mail_data,
array  $to_usr_ids 
)
private
Parameters
list<int>$to_usr_ids

Definition at line 626 of file class.ilMail.php.

References $user_id, createRecipient(), MailDeliveryData\getMessage(), replacePlaceholders(), and sendChanneledMails().

Referenced by distributeMail().

629  : void {
630  foreach ($to_usr_ids as $user_id) {
631  $recipient = $this->createRecipient($user_id);
632 
633  $this->sendChanneledMails(
634  $mail_data,
635  [$recipient],
636  $this->replacePlaceholders($mail_data->getMessage(), $user_id),
637  );
638  }
639  }
replacePlaceholders(string $message, int $usr_id=0)
sendChanneledMails(MailDeliveryData $mail_data, array $recipients, string $message)
int $user_id
createRecipient(int $user_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendMimeMail()

ilMail::sendMimeMail ( string  $to,
string  $cc,
string  $bcc,
string  $subject,
string  $message,
array  $attachments 
)
private
Parameters
list<string>$attachments

Definition at line 1217 of file class.ilMail.php.

References isSystemMail().

Referenced by delegateExternalEmails(), and sendMail().

1224  : void {
1225  $mailer = new ilMimeMail();
1226  $mailer->From($this->sender_factory->getSenderByUsrId($this->user_id));
1227  $mailer->To($to);
1228  $mailer->Subject(
1229  $subject,
1230  true,
1231  (string) ($this->context_parameters[self::PROP_CONTEXT_SUBJECT_PREFIX] ?? '')
1232  );
1233 
1234  if (!$this->isSystemMail()) {
1235  $message .= $this->signature_service->user($this->user_id);
1236  }
1237  $mailer->Body($message);
1238 
1239  if ($cc !== '') {
1240  $mailer->Cc($cc);
1241  }
1242 
1243  if ($bcc !== '') {
1244  $mailer->Bcc($bcc);
1245  }
1246 
1247 
1248  foreach ($attachments as $attachment) {
1249  $mailer->Attach(
1250  $this->mail_file_data->getAbsoluteAttachmentPoolPathByFilename($attachment),
1251  '',
1252  'inline',
1253  $attachment
1254  );
1255  }
1256 
1257  $mailer->Send();
1258  }
isSystemMail()
$message
Definition: xapiexit.php:31
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setMailOptionsByUserIdMap()

ilMail::setMailOptionsByUserIdMap ( array  $mail_options_by_usr_id_map)
Parameters
ilMailOptions[]$mail_options_by_usr_id_map

Definition at line 1443 of file class.ilMail.php.

References $mail_options_by_usr_id_map.

1443  : void
1444  {
1445  $this->mail_options_by_usr_id_map = $mail_options_by_usr_id_map;
1446  }
array $mail_options_by_usr_id_map

◆ setSaveInSentbox()

ilMail::setSaveInSentbox ( bool  $save_in_sentbox)

Definition at line 142 of file class.ilMail.php.

References $save_in_sentbox.

Referenced by __construct().

142  : void
143  {
144  $this->save_in_sentbox = $save_in_sentbox;
145  }
bool $save_in_sentbox
+ Here is the caller graph for this function:

◆ setUserInstanceById()

ilMail::setUserInstanceById ( array  $user_instances_by_id_map)
Parameters
array<int,ilObjUser>$user_instances_by_id_map

Definition at line 1426 of file class.ilMail.php.

References $user_instances_by_id_map.

1426  : void
1427  {
1428  $this->user_instances_by_id_map = $user_instances_by_id_map;
1429  }
array $user_instances_by_id_map

◆ updateDraft()

ilMail::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 = [] 
)
Parameters
list<string>$a_attachments

Definition at line 454 of file class.ilMail.php.

466  : int {
467  $this->db->update(
468  $this->table_mail,
469  [
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)],
482  ],
483  [
484  'mail_id' => ['integer', $a_draft_id],
485  ]
486  );
487 
488  return $a_draft_id;
489  }

◆ validateRecipients()

ilMail::validateRecipients ( string  $to,
string  $cc,
string  $bcc 
)
Returns
list<ilMailError>

Definition at line 1161 of file class.ilMail.php.

References Vendor\Package\$e, and checkRecipients().

Referenced by enqueue().

1161  : array
1162  {
1163  try {
1164  $errors = [];
1165  $errors = array_merge($errors, $this->checkRecipients($to));
1166  $errors = array_merge($errors, $this->checkRecipients($cc));
1167  $errors = array_merge($errors, $this->checkRecipients($bcc));
1168 
1169  if ($errors !== []) {
1170  return array_merge([new ilMailError('mail_following_rcp_not_valid')], $errors);
1171  }
1172  } catch (ilMailException $e) {
1173  return [new ilMailError('mail_generic_rcp_error', [$e->getMessage()])];
1174  }
1175 
1176  return [];
1177  }
checkRecipients(string $recipients)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ withContextId()

ilMail::withContextId ( string  $context_id)

Definition at line 108 of file class.ilMail.php.

References $context_id.

108  : self
109  {
110  $clone = clone $this;
111 
112  $clone->context_id = $context_id;
113 
114  return $clone;
115  }
string $context_id

◆ withContextParameters()

ilMail::withContextParameters ( array  $parameters)

Definition at line 117 of file class.ilMail.php.

117  : self
118  {
119  $clone = clone $this;
120 
121  $clone->context_parameters = $parameters;
122 
123  return $clone;
124  }

Field Documentation

◆ $append_installation_signature

bool ilMail::$append_installation_signature = false
private

Definition at line 39 of file class.ilMail.php.

Referenced by appendInstallationSignature().

◆ $append_user_signature

bool ilMail::$append_user_signature = false
private

Definition at line 40 of file class.ilMail.php.

◆ $context_id

string ilMail::$context_id = null
private

Definition at line 42 of file class.ilMail.php.

Referenced by withContextId().

◆ $context_parameters

array ilMail::$context_parameters = []
private

Definition at line 43 of file class.ilMail.php.

◆ $legal_documents

readonly Conductor ilMail::$legal_documents
private

Definition at line 51 of file class.ilMail.php.

◆ $mail_data

array ilMail::$mail_data = []
protected

◆ $mail_options_by_usr_id_map

array ilMail::$mail_options_by_usr_id_map = []
private

Definition at line 46 of file class.ilMail.php.

Referenced by setMailOptionsByUserIdMap().

◆ $max_recipient_character_length

int ilMail::$max_recipient_character_length = 998
private

Definition at line 50 of file class.ilMail.php.

◆ $save_in_sentbox

bool ilMail::$save_in_sentbox
private

Definition at line 38 of file class.ilMail.php.

Referenced by getSaveInSentbox(), and setSaveInSentbox().

◆ $signature_service

MailSignatureService ilMail::$signature_service
private

Definition at line 32 of file class.ilMail.php.

◆ $table_mail

string ilMail::$table_mail
private

Definition at line 34 of file class.ilMail.php.

◆ $table_mail_saved

string ilMail::$table_mail_saved
private

Definition at line 35 of file class.ilMail.php.

◆ $user_id

int ilMail::$user_id

◆ $user_instances_by_id_map

array ilMail::$user_instances_by_id_map = []
private

Definition at line 49 of file class.ilMail.php.

Referenced by setUserInstanceById().

◆ ILIAS_HOST

const string ilMail::ILIAS_HOST = 'ilias'

◆ PROP_CONTEXT_SUBJECT_PREFIX


The documentation for this class was generated from the following file: