ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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=null, 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)
 
 autoresponder ()
 
 withContextId (string $contextId)
 
 withContextParameters (array $parameters)
 
 existsRecipient (string $newRecipient, string $existingRecipients)
 
 setSaveInSentbox (bool $saveInSentbox)
 
 getSaveInSentbox ()
 
 getMailObjectReferenceId ()
 
 formatNamesForOutput (string $recipients)
 
 getPreviousMail (int $mailId)
 
 getNextMail (int $mailId)
 
 getMailsOfFolder (int $a_folder_id, array $filter=[])
 
 countMailsOfFolder (int $folderId)
 
 deleteMailsOfFolder (int $folderId)
 
 getMail (int $mailId)
 
 markRead (array $mailIds)
 
 markUnread (array $mailIds)
 
 moveMailsToFolder (array $mailIds, int $folderId)
 
 deleteMails (array $mailIds)
 
 getNewDraftId (int $folderId)
 
 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 $userInstanceByIdMap)
 
 setMailOptionsByUserIdMap (array $mailOptionsByUsrIdMap)
 
 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 ILIAS_HOST = 'ilias'
 
const PROP_CONTEXT_SUBJECT_PREFIX = 'subject_prefix'
 
int $user_id
 

Protected Attributes

array $mail_data = []
 

Private Member Functions

 isSystemMail ()
 
 readMailObjectReferenceId ()
 
 fetchMailData (?array $row)
 
 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=[])
 
 replacePlaceholders (string $message, int $usrId=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 $usrIdToExternalEmailAddressesMap)
 
 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 $onlyExternalAddresses=true)
 
 getCountRecipients (string $toRecipients, string $ccRecipients, string $bccRecipients, bool $onlyExternalAddresses=true)
 
 getEmailRecipients (string $recipients)
 
 getUserInstanceById (int $usrId)
 
 getMailOptionsByUserId (int $usrId)
 
 createRecipient (int $user_id)
 

Private Attributes

string $table_mail
 
string $table_mail_saved
 
bool $save_in_sentbox
 
bool $append_installation_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

Constructor & Destructor Documentation

◆ __construct()

ilMail::__construct ( private int  $a_user_id,
private ?ilMailAddressTypeFactory  $mail_address_type_factory = null,
private ?ilMailRfc822AddressParserFactory  $mail_address_parser_factory = null,
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 
)

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

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

75  {
76  global $DIC;
77  $this->logger = $logger ?? ilLoggerFactory::getLogger('mail');
78  $this->mail_address_type_factory = $mail_address_type_factory ?? new ilMailAddressTypeFactory(null, $logger);
79  $this->mail_address_parser_factory = $mail_address_parser_factory ?? new ilMailRfc822AddressParserFactory();
80  $this->event_handler = $event_handler ?? $DIC->event();
81  $this->db = $db ?? $DIC->database();
82  $this->lng = $lng ?? $DIC->language();
83  $this->actor = $actor ?? $DIC->user();
84  $this->mail_file_data = $mail_file_data ?? new ilFileDataMail($a_user_id);
85  $this->mail_options = $mail_options ?? new ilMailOptions($a_user_id);
86  $this->mailbox = $mailbox ?? new ilMailbox($a_user_id);
87 
88  $this->sender_factory = $sender_factory ?? $DIC->mail()->mime()->senderFactory();
89  $this->usr_id_by_login_callable = $usr_id_by_login_callable ?? static function (string $login): int {
90  return (int) ilObjUser::_lookupId($login);
91  };
92  $this->auto_responder_service = $auto_responder_service ?? $DIC->mail()->autoresponder();
93  $this->user_id = $a_user_id;
94  if (null === $this->mail_obj_ref_id) {
96  }
97  $this->lng->loadLanguageModule('mail');
98  $this->table_mail = 'mail';
99  $this->table_mail_saved = 'mail_saved';
100  $this->setSaveInSentbox(false);
101  $this->placeholder_resolver = $placeholder_resolver ?? $DIC->mail()->placeholderResolver();
102  $this->placeholder_to_empty_resolver = $placeholder_to_empty_resolver ?? $DIC->mail()->placeholderToEmptyResolver();
103  $this->legal_documents = $legal_documents ?? $DIC['legalDocuments'];
104  }
setSaveInSentbox(bool $saveInSentbox)
static getLogger(string $a_component_id)
Get component logger.
This class handles all operations on files (attachments) in directory ilias_data/mail.
static _lookupId($a_user_str)
readonly Conductor $legal_documents
global $DIC
Definition: feed.php:28
Class ilMailRfc822AddressParserFactory.
$lng
Mail Box class Base class for creating and handling mail boxes.
Class ilMailAddressTypeFactory.
readMailObjectReferenceId()
+ Here is the call graph for this function:

Member Function Documentation

◆ _getAutoGeneratedMessageString()

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

Definition at line 1340 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().

1340  : string
1341  {
1342  global $DIC;
1343 
1344  if (!($lang instanceof ilLanguage)) {
1346  }
1347 
1348  $lang->loadLanguageModule('mail');
1349 
1350  return sprintf(
1351  $lang->txt('mail_auto_generated_info'),
1352  $DIC->settings()->get('inst_name', 'ILIAS ' . ((int) ILIAS_VERSION_NUMERIC)),
1354  ) . "\n\n";
1355  }
const ILIAS_VERSION_NUMERIC
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
loadLanguageModule(string $a_module)
Load language module.
global $DIC
Definition: feed.php:28
static _getLanguage(string $a_lang_key='')
Get language object.
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 1357 of file class.ilMail.php.

References $DIC.

Referenced by ilMailBoxQuery\_getMailBoxListData(), ilMailFolderGUI\confirmDeleteMails(), ilMailFolderTableGUI\fetchTableData(), ilPDMailBlockGUI\getListItemForData(), ilPDMailGUI\getPDMailHTML(), ilMailFolderGUI\printMail(), ilMailSummaryNotification\send(), and ilMailTest\testGetIliasMailerName().

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

◆ _getInstallationSignature()

static ilMail::_getInstallationSignature ( )
static

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

References $DIC, ilUtil\_getHttpPath(), CLIENT_ID, and ILIAS_WEB_DIR.

Referenced by ilObjUserGUI\__sendProfileMail(), ilForumMailNotification\addLinkToMail(), ilSystemNotification\compose(), ilForumMailEventNotificationSender\createAttachmentLinkText(), ilTimingsCronReminder\fillObjectListForMailBody(), ilCronDeleteInactiveUserReminderMailNotification\initLanguage(), ilMailSummaryNotification\send(), ILIAS\Wiki\Notification\NotificationGUI\send(), ILIAS\Mail\Cron\ExpiredOrOrphanedMails\MailNotification\send(), ILIAS\LegalDocuments\ConsumerToolbox\Mail\sendGeneric(), ilAccountRegistrationMail\sendLanguageVariableBasedAccountMail(), ilWikiUtil\sendNotification(), and ilObjSurveyGUI\sendUserResultsMail().

1379  : string
1380  {
1381  global $DIC;
1382 
1383  $signature = $DIC->settings()->get('mail_system_sys_signature', '');
1384 
1385  $clientUrl = ilUtil::_getHttpPath();
1386  $clientdirs = glob(ILIAS_WEB_DIR . '/*', GLOB_ONLYDIR);
1387  if (is_array($clientdirs) && count($clientdirs) > 1) {
1388  $clientUrl .= '/login.php?client_id=' . CLIENT_ID; // #18051
1389  }
1390 
1391  $placeholders = [
1392  'INSTALLATION_NAME' => $DIC['ilClientIniFile']->readVariable('client', 'name'),
1393  'INSTALLATION_DESC' => $DIC['ilClientIniFile']->readVariable('client', 'description'),
1394  'ILIAS_URL' => $clientUrl,
1395  ];
1396 
1397  $signature = $DIC->mail()->mustacheFactory()->getBasicEngine()->render($signature, $placeholders);
1398 
1399  if (!preg_match('/^[\n\r]+/', (string) $signature)) {
1400  $signature = "\n" . $signature;
1401  }
1402 
1403  return $signature;
1404  }
global $DIC
Definition: feed.php:28
const CLIENT_ID
Definition: constants.php:41
static _getHttpPath()
const ILIAS_WEB_DIR
Definition: constants.php:45
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ appendInstallationSignature()

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

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

References $append_installation_signature.

Referenced by enqueue().

1370  {
1371  if (null === $a_flag) {
1373  }
1374 
1375  $this->append_installation_signature = $a_flag;
1376  return $this;
1377  }
bool $append_installation_signature
+ Here is the caller graph for this function:

◆ autoresponder()

ilMail::autoresponder ( )

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

107  {
108  return $this->auto_responder_service;
109  }

◆ checkMail()

ilMail::checkMail ( string  $to,
string  $cc,
string  $bcc,
string  $subject 
)
private
Returns
ilMailError[]

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

References ilStr\strLen().

Referenced by enqueue().

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

◆ checkRecipients()

ilMail::checkRecipients ( string  $recipients)
private
Returns
ilMailError[]
Exceptions
ilMailException

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

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

Referenced by validateRecipients().

889  : array
890  {
891  $errors = [];
892 
893  try {
894  $addresses = $this->parseAddresses($recipients);
895  foreach ($addresses as $address) {
896  $address_type = $this->mail_address_type_factory->getByPrefix($address);
897  if (!$address_type->validate($this->user_id)) {
898  $errors[] = $address_type->getErrors();
899  }
900  }
901  } catch (Exception $e) {
902  $colonPosition = strpos($e->getMessage(), ':');
903  throw new ilMailException(
904  ($colonPosition === false) ? $e->getMessage() : substr($e->getMessage(), $colonPosition + 2),
905  $e->getCode(),
906  $e
907  );
908  }
909 
910  return array_merge(...$errors);
911  }
parseAddresses(string $addresses)
Explode recipient string, allowed separators are ',' ';' ' '.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ countMailsOfFolder()

ilMail::countMailsOfFolder ( int  $folderId)

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

References $res.

268  : int
269  {
270  $res = $this->db->queryF(
271  "SELECT COUNT(*) FROM $this->table_mail WHERE user_id = %s AND folder_id = %s",
272  ['integer', 'integer'],
273  [$this->user_id, $folderId]
274  );
275 
276  return $this->db->numRows($res);
277  }
$res
Definition: ltiservices.php:69

◆ createRecipient()

ilMail::createRecipient ( int  $user_id)
private

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

References getMailOptionsByUserId(), and getUserInstanceById().

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

1473  : Recipient
1474  {
1475  return new Recipient(
1476  $user_id,
1477  $this->getUserInstanceById($user_id),
1479  $this->legal_documents
1480  );
1481  }
getUserInstanceById(int $usrId)
int $user_id
getMailOptionsByUserId(int $usrId)
+ 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  $usrIdToExternalEmailAddressesMap 
)
private
Parameters
string[]$attachments
array<int,string[]>$usrIdToExternalEmailAddressesMap

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

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

Referenced by sendChanneledMails().

781  : void {
782  if (1 === count($usrIdToExternalEmailAddressesMap)) {
783  $usrIdToExternalEmailAddressesMap = array_values($usrIdToExternalEmailAddressesMap);
784  $firstAddresses = current($usrIdToExternalEmailAddressesMap);
785 
786  $this->sendMimeMail(
787  implode(',', $firstAddresses),
788  '',
789  '',
790  $subject,
791  $message,
792  $attachments
793  );
794  } elseif (count($usrIdToExternalEmailAddressesMap) > 1) {
795  $flattenEmailAddresses = iterator_to_array(new RecursiveIteratorIterator(new RecursiveArrayIterator(
796  $usrIdToExternalEmailAddressesMap
797  )), false);
798 
799  $flattenEmailAddresses = array_unique($flattenEmailAddresses);
800 
801  // https://mantis.ilias.de/view.php?id=23981 and https://www.ietf.org/rfc/rfc2822.txt
802  $remainingAddresses = '';
803  foreach ($flattenEmailAddresses as $emailAddress) {
804  $sep = '';
805  if ($remainingAddresses !== '') {
806  $sep = ',';
807  }
808 
809  $recipientsLineLength = ilStr::strLen($remainingAddresses) +
810  ilStr::strLen($sep . $emailAddress);
811  if ($recipientsLineLength >= $this->max_recipient_character_length) {
812  $this->sendMimeMail(
813  '',
814  '',
815  $remainingAddresses,
816  $subject,
817  $message,
818  $attachments
819  );
820 
821  $remainingAddresses = '';
822  $sep = '';
823  }
824 
825  $remainingAddresses .= ($sep . $emailAddress);
826  }
827 
828  if ('' !== $remainingAddresses) {
829  $this->sendMimeMail(
830  '',
831  '',
832  $remainingAddresses,
833  $subject,
834  $message,
835  $attachments
836  );
837  }
838  }
839  }
sendMimeMail(string $to, string $cc, string $bcc, string $subject, string $message, array $attachments)
static strLen(string $a_string)
Definition: class.ilStr.php:63
$message
Definition: xapiexit.php:32
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteMails()

ilMail::deleteMails ( array  $mailIds)
Parameters
int[]$mailIds

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

References $id.

Referenced by deleteMailsOfFolder(), and sendMail().

379  : void
380  {
381  $mailIds = array_filter(array_map('intval', $mailIds));
382  foreach ($mailIds as $id) {
383  $this->db->manipulateF(
384  "DELETE FROM $this->table_mail WHERE user_id = %s AND mail_id = %s",
385  ['integer', 'integer'],
386  [$this->user_id, $id]
387  );
388  $this->mail_file_data->deassignAttachmentFromDirectory($id);
389  }
390  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the caller graph for this function:

◆ deleteMailsOfFolder()

ilMail::deleteMailsOfFolder ( int  $folderId)

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

References deleteMails(), and getMailsOfFolder().

279  : void
280  {
281  $mails = $this->getMailsOfFolder($folderId);
282  foreach ($mails as $mail_data) {
283  $this->deleteMails([$mail_data['mail_id']]);
284  }
285  }
array $mail_data
getMailsOfFolder(int $a_folder_id, array $filter=[])
deleteMails(array $mailIds)
+ Here is the call graph for this function:

◆ distributeMail()

ilMail::distributeMail ( MailDeliveryData  $mail_data)
private

Definition at line 595 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().

595  : bool
596  {
597  $this->auto_responder_service->emptyAutoresponderData();
598  $to_usr_ids = $this->getUserIds([$mail_data->getTo()]);
599  $this->logger->debug(sprintf(
600  "Parsed TO user ids from given recipients for serial letter notification: %s",
601  implode(', ', $to_usr_ids)
602  ));
603 
604  $other_usr_ids = $this->getUserIds([$mail_data->getCc(), $mail_data->getBcc()]);
605  $cc_bcc_recipients = array_map(
606  $this->createRecipient(...),
607  $other_usr_ids
608  );
609  $this->logger->debug(sprintf(
610  "Parsed CC/BCC user ids from given recipients for serial letter notification: %s",
611  implode(', ', $other_usr_ids)
612  ));
613 
614  if ($mail_data->isUsePlaceholder()) {
615  $this->sendMailWithReplacedPlaceholder($mail_data, $to_usr_ids);
616  $this->sendMailWithReplacedEmptyPlaceholder($mail_data, $cc_bcc_recipients);
617  } else {
618  $this->sendMailWithoutReplacedPlaceholder($mail_data, $to_usr_ids, $cc_bcc_recipients);
619  }
620 
621  $this->auto_responder_service->disableAutoresponder();
622  $this->auto_responder_service->handleAutoresponderMails($this->user_id);
623 
624  return true;
625  }
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
string[]$a_attachment
Returns
ilMailError[]

Definition at line 972 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().

980  : array {
981  global $DIC;
982 
983  $sanitizeMb4Encoding = new Utf8Mb4Sanitizer();
984  $a_m_subject = $sanitizeMb4Encoding->transform($a_m_subject);
985  $a_m_message = $sanitizeMb4Encoding->transform($a_m_message);
986 
987  $this->logger->info(
988  "New mail system task:" .
989  " To: " . $a_rcp_to .
990  " | CC: " . $a_rcp_cc .
991  " | BCC: " . $a_rcp_bcc .
992  " | Subject: " . $a_m_subject .
993  " | Attachments: " . print_r($a_attachment, true)
994  );
995 
996  if ($a_attachment && !$this->mail_file_data->checkFilesExist($a_attachment)) {
997  return [new ilMailError('mail_attachment_file_not_exist', [$a_attachment])];
998  }
999 
1000  $errors = $this->checkMail($a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_m_subject);
1001  if ($errors !== []) {
1002  return $errors;
1003  }
1004 
1005  $errors = $this->validateRecipients($a_rcp_to, $a_rcp_cc, $a_rcp_bcc);
1006  if ($errors !== []) {
1007  return $errors;
1008  }
1009 
1010  $rcp_to = $a_rcp_to;
1011  $rcp_cc = $a_rcp_cc;
1012  $rcp_bcc = $a_rcp_bcc;
1013 
1014  $numberOfExternalAddresses = $this->getCountRecipients($rcp_to, $rcp_cc, $rcp_bcc);
1015  if (
1016  $numberOfExternalAddresses > 0 &&
1017  !$this->isSystemMail() &&
1018  !$DIC->rbac()->system()->checkAccessOfUser($this->user_id, 'smtp_mail', $this->mail_obj_ref_id)
1019  ) {
1020  return [new ilMailError('mail_no_permissions_write_smtp')];
1021  }
1022 
1023  if ($this->appendInstallationSignature()) {
1024  $a_m_message .= self::_getInstallationSignature();
1025  }
1026 
1029  $rcp_to,
1030  $rcp_cc,
1031  $rcp_bcc,
1032  $a_m_subject,
1033  $a_m_message,
1034  $a_attachment,
1035  $a_use_placeholders
1036  );
1037  return $this->sendMail($mail_data);
1038  }
1039 
1040  $taskFactory = $DIC->backgroundTasks()->taskFactory();
1041  $taskManager = $DIC->backgroundTasks()->taskManager();
1042 
1043  $bucket = new BasicBucket();
1044  $bucket->setUserId($this->user_id);
1045 
1046  $task = $taskFactory->createTask(ilMailDeliveryJob::class, [
1047  $this->user_id,
1048  $rcp_to,
1049  $rcp_cc,
1050  $rcp_bcc,
1051  $a_m_subject,
1052  $a_m_message,
1053  serialize($a_attachment),
1054  $a_use_placeholders,
1055  $this->getSaveInSentbox(),
1056  (string) $this->context_id,
1057  serialize(array_merge(
1058  $this->context_parameters,
1059  [
1060  'auto_responder' => $this->auto_responder_service->isAutoresponderEnabled()
1061  ]
1062  ))
1063  ]);
1064  $interaction = $taskFactory->createTask(ilMailDeliveryJobUserInteraction::class, [
1065  $task,
1066  $this->user_id,
1067  ]);
1068 
1069  $bucket->setTask($interaction);
1070  $bucket->setTitle($this->lng->txt('mail_bg_task_title'));
1071  $bucket->setDescription(sprintf($this->lng->txt('mail_bg_task_desc'), $a_m_subject));
1072 
1073  $this->logger->info('Delegated delivery to background task');
1074  $taskManager->run($bucket);
1075 
1076  return [];
1077  }
Class ilMailError.
array $mail_data
appendInstallationSignature(bool $a_flag=null)
checkMail(string $to, string $cc, string $bcc, string $subject)
getCountRecipients(string $toRecipients, string $ccRecipients, string $bccRecipients, bool $onlyExternalAddresses=true)
const CONTEXT_CRON
global $DIC
Definition: feed.php:28
isSystemMail()
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  $newRecipient,
string  $existingRecipients 
)

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

References parseAddresses().

134  : bool
135  {
136  $newAddresses = new ilMailAddressListImpl($this->parseAddresses($newRecipient));
137  $addresses = new ilMailAddressListImpl($this->parseAddresses($existingRecipients));
138 
139  $list = new ilMailDiffAddressList($newAddresses, $addresses);
140 
141  $diffedAddresses = $list->value();
142 
143  return $diffedAddresses === [];
144  }
Class ilMailDiffAddressList.
parseAddresses(string $addresses)
Explode recipient string, allowed separators are &#39;,&#39; &#39;;&#39; &#39; &#39;.
Class ilMailAddressListImpl.
+ Here is the call graph for this function:

◆ fetchMailData()

ilMail::fetchMailData ( ?array  $row)
private

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

References ILIAS\Repository\int().

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

392  : ?array
393  {
394  if (!is_array($row) || empty($row)) {
395  return null;
396  }
397 
398  if (isset($row['attachments'])) {
399  $unserialized = unserialize(stripslashes($row['attachments']), ['allowed_classes' => false]);
400  $row['attachments'] = is_array($unserialized) ? $unserialized : [];
401  } else {
402  $row['attachments'] = [];
403  }
404 
405  if (isset($row['tpl_ctx_params']) && is_string($row['tpl_ctx_params'])) {
406  $decoded = json_decode($row['tpl_ctx_params'], true, 512, JSON_THROW_ON_ERROR);
407  $row['tpl_ctx_params'] = (array) ($decoded ?? []);
408  } else {
409  $row['tpl_ctx_params'] = [];
410  }
411 
412  if (isset($row['mail_id'])) {
413  $row['mail_id'] = (int) $row['mail_id'];
414  }
415 
416  if (isset($row['user_id'])) {
417  $row['user_id'] = (int) $row['user_id'];
418  }
419 
420  if (isset($row['folder_id'])) {
421  $row['folder_id'] = (int) $row['folder_id'];
422  }
423 
424  if (isset($row['sender_id'])) {
425  $row['sender_id'] = (int) $row['sender_id'];
426  }
427 
428  if (isset($row['use_placeholders'])) {
429  $row['use_placeholders'] = (bool) $row['use_placeholders'];
430  }
431 
432  $null_to_string_properties = ['m_subject', 'm_message', 'rcp_to', 'rcp_cc', 'rcp_bcc'];
433  foreach ($null_to_string_properties as $null_to_string_property) {
434  if (!isset($row[$null_to_string_property])) {
435  $row[$null_to_string_property] = '';
436  }
437  }
438 
439  return $row;
440  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ formatLinebreakMessage()

ilMail::formatLinebreakMessage ( string  $message)

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

References $message.

1468  : string
1469  {
1470  return $message;
1471  }
$message
Definition: xapiexit.php:32

◆ formatNamesForOutput()

ilMail::formatNamesForOutput ( string  $recipients)

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

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

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

◆ getCountRecipient()

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

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

References parseAddresses().

Referenced by getCountRecipients().

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

◆ getCountRecipients()

ilMail::getCountRecipients ( string  $toRecipients,
string  $ccRecipients,
string  $bccRecipients,
bool  $onlyExternalAddresses = true 
)
private

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

References getCountRecipient().

Referenced by enqueue(), and sendMail().

1317  : int {
1318  return (
1319  $this->getCountRecipient($toRecipients, $onlyExternalAddresses) +
1320  $this->getCountRecipient($ccRecipients, $onlyExternalAddresses) +
1321  $this->getCountRecipient($bccRecipients, $onlyExternalAddresses)
1322  );
1323  }
getCountRecipient(string $recipients, bool $onlyExternalAddresses=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 1325 of file class.ilMail.php.

References parseAddresses().

Referenced by sendMail().

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

◆ getMail()

ilMail::getMail ( int  $mailId)

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

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

287  : ?array
288  {
289  $res = $this->db->queryF(
290  "SELECT * FROM $this->table_mail WHERE user_id = %s AND mail_id = %s",
291  ['integer', 'integer'],
292  [$this->user_id, $mailId]
293  );
294 
295  $this->mail_data = $this->fetchMailData($this->db->fetchAssoc($res));
296 
297  return $this->mail_data;
298  }
$res
Definition: ltiservices.php:69
array $mail_data
fetchMailData(?array $row)
+ Here is the call graph for this function:

◆ getMailObjectReferenceId()

ilMail::getMailObjectReferenceId ( )

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

161  : int
162  {
163  return $this->mail_obj_ref_id;
164  }

◆ getMailOptionsByUserId()

ilMail::getMailOptionsByUserId ( int  $usrId)
private

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

Referenced by createRecipient(), and sendChanneledMails().

1451  : ilMailOptions
1452  {
1453  if (!isset($this->mail_options_by_usr_id_map[$usrId])) {
1454  $this->mail_options_by_usr_id_map[$usrId] = new ilMailOptions($usrId);
1455  }
1456 
1457  return $this->mail_options_by_usr_id_map[$usrId];
1458  }
+ Here is the caller graph for this function:

◆ getMailsOfFolder()

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

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

References $res, and fetchMailData().

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

237  : array
238  {
239  $mails = [];
240 
241  $query =
242  "SELECT sender_id, m_subject, mail_id, m_status, send_time, import_name " .
243  "FROM $this->table_mail " .
244  "LEFT JOIN object_data ON obj_id = sender_id " .
245  "WHERE user_id = %s AND folder_id = %s " .
246  "AND ((sender_id > 0 AND sender_id IS NOT NULL AND obj_id IS NOT NULL) " .
247  "OR (sender_id = 0 OR sender_id IS NULL))";
248 
249  if (isset($filter['status']) && $filter['status'] !== '') {
250  $query .= ' AND m_status = ' . $this->db->quote($filter['status'], 'text');
251  }
252 
253  $query .= " ORDER BY send_time DESC";
254 
255  $res = $this->db->queryF(
256  $query,
257  ['integer', 'integer'],
258  [$this->user_id, $a_folder_id]
259  );
260 
261  while ($row = $this->db->fetchAssoc($res)) {
262  $mails[] = $this->fetchMailData($row);
263  }
264 
265  return array_filter($mails);
266  }
$res
Definition: ltiservices.php:69
fetchMailData(?array $row)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNewDraftId()

ilMail::getNewDraftId ( int  $folderId)

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

442  : int
443  {
444  $nextId = $this->db->nextId($this->table_mail);
445  $this->db->insert($this->table_mail, [
446  'mail_id' => ['integer', $nextId],
447  'user_id' => ['integer', $this->user_id],
448  'folder_id' => ['integer', $folderId],
449  'sender_id' => ['integer', $this->user_id],
450  ]);
451 
452  return $nextId;
453  }

◆ getNextMail()

ilMail::getNextMail ( int  $mailId)

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

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

216  : ?array
217  {
218  $this->db->setLimit(1, 0);
219 
220  $query = implode(' ', [
221  "SELECT b.* FROM $this->table_mail a",
222  "INNER JOIN $this->table_mail b ON b.folder_id = a.folder_id",
223  'AND b.user_id = a.user_id AND b.send_time < a.send_time',
224  'WHERE a.user_id = %s AND a.mail_id = %s ORDER BY b.send_time DESC',
225  ]);
226  $res = $this->db->queryF(
227  $query,
228  ['integer', 'integer'],
229  [$this->user_id, $mailId]
230  );
231 
232  $this->mail_data = $this->fetchMailData($this->db->fetchAssoc($res));
233 
234  return $this->mail_data;
235  }
$res
Definition: ltiservices.php:69
array $mail_data
fetchMailData(?array $row)
+ Here is the call graph for this function:

◆ getPreviousMail()

ilMail::getPreviousMail ( int  $mailId)

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

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

195  : ?array
196  {
197  $this->db->setLimit(1, 0);
198 
199  $query = implode(' ', [
200  "SELECT b.* FROM $this->table_mail a",
201  "INNER JOIN $this->table_mail b ON b.folder_id = a.folder_id",
202  'AND b.user_id = a.user_id AND b.send_time > a.send_time',
203  'WHERE a.user_id = %s AND a.mail_id = %s ORDER BY b.send_time ASC',
204  ]);
205  $res = $this->db->queryF(
206  $query,
207  ['integer', 'integer'],
208  [$this->user_id, $mailId]
209  );
210 
211  $this->mail_data = $this->fetchMailData($this->db->fetchAssoc($res));
212 
213  return $this->mail_data;
214  }
$res
Definition: ltiservices.php:69
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 1406 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(), ILIAS\Portfolio\Notification\SharedNotification\send(), ilMailSummaryNotification\send(), ilLMMailNotification\send(), ILIAS\Mail\Cron\ExpiredOrOrphanedMails\MailNotification\send(), ilDataCollectionMailNotification\send(), ilBuddySystemNotification\send(), ilSessionMembershipMailNotification\send(), ilLearningSequenceMembershipMailNotification\send(), ilIndividualAssessmentPrimitiveInternalNotificator\send(), ilCalendarMailNotification\send(), ilGroupMembershipMailNotification\send(), ilExerciseMailNotification\send(), ilCourseMembershipMailNotification\send(), ilTestMailNotification\sendAdvancedNotification(), ilExerciseMailNotification\sendExerciseNotification(), ilTestMailNotification\sendSimpleNotification(), and ilObjSurveyGUI\sendUserResultsMail().

1406  : string
1407  {
1408  global $DIC;
1409 
1410  $lang = ($a_language instanceof ilLanguage) ? $a_language : $DIC->language();
1411  $lang->loadLanguageModule('mail');
1412 
1413  $gender = ilObjUser::_lookupGender($a_usr_id);
1414  $gender = $gender ?: 'n';
1415  $name = ilObjUser::_lookupName($a_usr_id);
1416 
1417  if ($name['firstname'] === '') {
1418  return $lang->txt('mail_salutation_anonymous') . ',';
1419  }
1420 
1421  return
1422  $lang->txt('mail_salutation_' . $gender) . ' ' .
1423  ($name['title'] ? $name['title'] . ' ' : '') .
1424  ($name['firstname'] ? $name['firstname'] . ' ' : '') .
1425  $name['lastname'] . ',';
1426  }
static _lookupName(int $a_user_id)
lookup user name
static _lookupGender(int $a_user_id)
global $DIC
Definition: feed.php:28
$lang
Definition: xapiexit.php:26
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSaveInSentbox()

ilMail::getSaveInSentbox ( )

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

References $save_in_sentbox.

Referenced by enqueue(), and sendMail().

151  : bool
152  {
153  return $this->save_in_sentbox;
154  }
bool $save_in_sentbox
+ Here is the caller graph for this function:

◆ getSubjectSentFolderId()

ilMail::getSubjectSentFolderId ( )
private

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

References isSystemMail().

Referenced by saveInSentbox(), and sendInternalMail().

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

◆ getUserIds()

ilMail::getUserIds ( array  $recipients)
private
Parameters
string[]$recipients
Returns
int[]

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

References parseAddresses().

Referenced by distributeMail().

845  : array
846  {
847  $parsed_usr_ids = [];
848 
849  $joined_recipients = implode(',', array_filter(array_map('trim', $recipients)));
850 
851  $addresses = $this->parseAddresses($joined_recipients);
852  foreach ($addresses as $address) {
853  $address_type = $this->mail_address_type_factory->getByPrefix($address);
854  $parsed_usr_ids[] = $address_type->resolve();
855  }
856 
857  return array_unique(array_merge(...$parsed_usr_ids));
858  }
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  $usrId)
private

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

References Vendor\Package\$e.

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

1428  : ?ilObjUser
1429  {
1430  if (!array_key_exists($usrId, $this->user_instances_by_id_map)) {
1431  try {
1432  $user = new ilObjUser($usrId);
1433  } catch (Exception $e) {
1434  $user = null;
1435  }
1436 
1437  $this->user_instances_by_id_map[$usrId] = $user;
1438  }
1439 
1440  return $this->user_instances_by_id_map[$usrId];
1441  }
+ Here is the caller graph for this function:

◆ isSystemMail()

ilMail::isSystemMail ( )
private

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

References ANONYMOUS_USER_ID.

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

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

◆ markRead()

ilMail::markRead ( array  $mailIds)
Parameters
int[]$mailIds

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

References $user_id.

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

◆ markUnread()

ilMail::markUnread ( array  $mailIds)
Parameters
int[]$mailIds

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

References $user_id.

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

◆ moveMailsToFolder()

ilMail::moveMailsToFolder ( array  $mailIds,
int  $folderId 
)
Parameters
int[]$mailIds

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

References $user_id.

345  : bool
346  {
347  $values = [];
348  $types = [];
349 
350  $mailIds = array_filter(array_map('intval', $mailIds));
351 
352  if ([] === $mailIds) {
353  return false;
354  }
355 
356  $query =
357  "UPDATE $this->table_mail " .
358  "INNER JOIN mail_obj_data " .
359  "ON mail_obj_data.obj_id = %s AND mail_obj_data.user_id = %s " .
360  "SET $this->table_mail.folder_id = mail_obj_data.obj_id " .
361  "WHERE $this->table_mail.user_id = %s";
362  $types[] = 'integer';
363  $types[] = 'integer';
364  $types[] = 'integer';
365  $values[] = $folderId;
366  $values[] = $this->user_id;
367  $values[] = $this->user_id;
368 
369  $query .= ' AND ' . $this->db->in('mail_id', $mailIds, false, 'integer');
370 
371  $affectedRows = $this->db->manipulateF($query, $types, $values);
372 
373  return $affectedRows > 0;
374  }
int $user_id

◆ parseAddresses()

ilMail::parseAddresses ( string  $addresses)
private

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

Returns
ilMailAddress[]

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

References ILIAS\Repository\logger().

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

1274  : array
1275  {
1276  if ($addresses !== '') {
1277  $this->logger->debug(sprintf(
1278  "Started parsing of recipient string: %s",
1279  $addresses
1280  ));
1281  }
1282 
1283  $parser = $this->mail_address_parser_factory->getParser($addresses);
1284  $parsedAddresses = $parser->parse();
1285 
1286  if ($addresses !== '') {
1287  $this->logger->debug(sprintf(
1288  "Parsed addresses: %s",
1289  implode(',', array_map(static function (ilMailAddress $address): string {
1290  return (string) $address;
1291  }, $parsedAddresses))
1292  ));
1293  }
1294 
1295  return $parsedAddresses;
1296  }
Class ilMailAddress.
+ 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
string[]$a_attachments

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

References retrieveFromStage().

Referenced by retrieveFromStage().

927  : bool {
928  $this->db->replace(
929  $this->table_mail_saved,
930  [
931  'user_id' => ['integer', $this->user_id],
932  ],
933  [
934  'attachments' => ['clob', serialize($a_attachments)],
935  'rcp_to' => ['clob', $a_rcp_to],
936  'rcp_cc' => ['clob', $a_rcp_cc],
937  'rcp_bcc' => ['clob', $a_rcp_bcc],
938  'm_subject' => ['text', $a_m_subject],
939  'm_message' => ['clob', $a_m_message],
940  'use_placeholders' => ['integer', (int) $a_use_placeholders],
941  'tpl_ctx_id' => ['text', $a_tpl_context_id],
942  'tpl_ctx_params' => ['blob', json_encode((array) $a_tpl_ctx_params, JSON_THROW_ON_ERROR)],
943  ]
944  );
945 
946  $this->retrieveFromStage();
947 
948  return true;
949  }
retrieveFromStage()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readMailObjectReferenceId()

ilMail::readMailObjectReferenceId ( )
private

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

References ilMailGlobalServices\getMailObjectRefId().

Referenced by __construct().

156  : void
157  {
158  $this->mail_obj_ref_id = ilMailGlobalServices::getMailObjectRefId();
159  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ replacePlaceholders()

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

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

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

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

563  : string {
564  try {
565  if ($this->context_id) {
567  } else {
569  }
570 
571  $user = $usrId > 0 ? $this->getUserInstanceById($usrId) : null;
572  $message = $this->placeholder_resolver->resolve(
573  $context,
574  $message,
575  $user,
576  $this->context_parameters
577  );
578  } catch (Exception $e) {
579  $this->logger->error(sprintf(
580  '%s has been called with invalid context: %s / %s',
581  __METHOD__,
582  $e->getMessage(),
583  $e->getTraceAsString()
584  ));
585  }
586 
587  return $message;
588  }
$context
Definition: webdav.php:31
getUserInstanceById(int $usrId)
$message
Definition: xapiexit.php:32
+ 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 590 of file class.ilMail.php.

Referenced by sendMailWithReplacedEmptyPlaceholder().

590  : string
591  {
592  return $this->placeholder_to_empty_resolver->resolve($message);
593  }
$message
Definition: xapiexit.php:32
+ Here is the caller graph for this function:

◆ retrieveFromStage()

ilMail::retrieveFromStage ( )

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

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

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

951  : array
952  {
953  $res = $this->db->queryF(
954  "SELECT * FROM $this->table_mail_saved WHERE user_id = %s",
955  ['integer'],
956  [$this->user_id]
957  );
958 
959  $this->mail_data = $this->fetchMailData($this->db->fetchAssoc($res));
960  if (!is_array($this->mail_data)) {
961  $this->persistToStage($this->user_id, [], '', '', '', '', '', false);
962  }
963 
964  return $this->mail_data;
965  }
$res
Definition: ltiservices.php:69
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
string[]$attachments

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

1257  : void
1258  {
1259  $this->db->update(
1260  $this->table_mail_saved,
1261  [
1262  'attachments' => ['clob', serialize($attachments)],
1263  ],
1264  [
1265  'user_id' => ['integer', $this->user_id],
1266  ]
1267  );
1268  }

◆ saveInSentbox()

ilMail::saveInSentbox ( array  $attachment,
string  $to,
string  $cc,
string  $bcc,
string  $subject,
string  $message 
)
private
Parameters
string[]$attachment

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

References getSubjectSentFolderId(), and sendInternalMail().

Referenced by sendMail().

1198  : int {
1199  return $this->sendInternalMail(
1200  $this->getSubjectSentFolderId(),
1201  $this->user_id,
1202  $attachment,
1203  $to,
1204  $cc,
1205  $bcc,
1206  'read',
1207  $subject,
1208  $message,
1209  $this->user_id
1210  );
1211  }
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=[])
$message
Definition: xapiexit.php:32
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
Recipient[]$recipients
Exceptions
JsonException

Definition at line 674 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().

678  : void {
679  $usrIdToExternalEmailAddressesMap = [];
680 
681  foreach ($recipients as $recipient) {
682  if (!$recipient->isUser()) {
683  $this->logger->critical(sprintf(
684  "Skipped recipient with id %s (User not found)",
685  $recipient->getUserId()
686  ));
687  continue;
688  }
689 
690  $can_read_internal = $recipient->evaluateInternalMailReadability();
691  if ($this->isSystemMail() && !$can_read_internal->isOk()) {
692  $this->logger->debug(sprintf(
693  'Skipped recipient with id %s and reason: %s',
694  $recipient->getUserId(),
695  is_string($can_read_internal->error()) ? $can_read_internal->error() : $can_read_internal->error()->getMessage()
696  ));
697  continue;
698  }
699 
700  if ($recipient->isUserActive()) {
701  if (!$can_read_internal->isOk() || $recipient->userWantsToReceiveExternalMails()) {
702  $emailAddresses = $recipient->getExternalMailAddress();
703  $usrIdToExternalEmailAddressesMap[$recipient->getUserId()] = $emailAddresses;
704 
705  if ($recipient->onlyToExternalMailAddress()) {
706  $this->logger->debug(sprintf(
707  "Recipient with id %s will only receive external emails sent to: %s",
708  $recipient->getUserId(),
709  implode(', ', $emailAddresses)
710  ));
711  continue;
712  }
713 
714  $this->logger->debug(sprintf(
715  "Recipient with id %s will additionally receive external emails " .
716  "(because the user wants to receive it externally, or the user cannot access " .
717  "the internal mail system) sent to: %s",
718  $recipient->getUserId(),
719  implode(', ', $emailAddresses)
720  ));
721  } else {
722  $this->logger->debug(sprintf(
723  "Recipient with id %s is does not want to receive external emails",
724  $recipient->getUserId()
725  ));
726  }
727  } else {
728  $this->logger->debug(sprintf(
729  "Recipient with id %s is inactive and will not receive external emails",
730  $recipient->getUserId()
731  ));
732  }
733 
734  $mbox = clone $this->mailbox;
735  $mbox->setUsrId($recipient->getUserId());
736  $recipientInboxId = $mbox->getInboxFolder();
737 
738  $internalMailId = $this->sendInternalMail(
739  $recipientInboxId,
740  $this->user_id,
741  $mail_data->getAttachments(),
742  $mail_data->getTo(),
743  $mail_data->getCc(),
744  '',
745  'unread',
746  $mail_data->getSubject(),
747  $message,
748  $recipient->getUserId()
749  );
750 
751  $mail_receiver_options = $this->getMailOptionsByUserId($this->user_id);
752 
753  $this->auto_responder_service->enqueueAutoresponderIfEnabled(
754  $recipient->getUserId(),
755  $recipient->getMailOptions(),
756  $mail_receiver_options,
757  );
758 
759  if ($mail_data->getAttachments() !== []) {
760  $this->mail_file_data->assignAttachmentsToDirectory($internalMailId, $mail_data->getInternalMailId());
761  }
762  }
763 
764  $this->delegateExternalEmails(
765  $mail_data->getSubject(),
766  $mail_data->getAttachments(),
767  $message,
768  $usrIdToExternalEmailAddressesMap
769  );
770  }
delegateExternalEmails(string $subject, array $attachments, string $message, array $usrIdToExternalEmailAddressesMap)
isSystemMail()
getMailOptionsByUserId(int $usrId)
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=[])
$message
Definition: xapiexit.php:32
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendInternalMail()

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

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

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

Referenced by saveInSentbox(), and sendChanneledMails().

509  : int {
510  $usrId = $usrId ?: $this->user_id;
511 
512  if ($usePlaceholders) {
513  $message = $this->replacePlaceholders($message, $usrId);
514  }
515  $message = str_ireplace(["<br />", "<br>", "<br/>"], "\n", $message);
516 
517  $nextId = $this->db->nextId($this->table_mail);
518  $this->db->insert($this->table_mail, [
519  'mail_id' => ['integer', $nextId],
520  'user_id' => ['integer', $usrId],
521  'folder_id' => ['integer', $folderId],
522  'sender_id' => ['integer', $senderUsrId],
523  'attachments' => ['clob', serialize($attachments)],
524  'send_time' => ['timestamp', date('Y-m-d H:i:s')],
525  'rcp_to' => ['clob', $to],
526  'rcp_cc' => ['clob', $cc],
527  'rcp_bcc' => ['clob', $bcc],
528  'm_status' => ['text', $status],
529  'm_subject' => ['text', $subject],
530  'm_message' => ['clob', $message],
531  'tpl_ctx_id' => ['text', $templateContextId],
532  'tpl_ctx_params' => ['blob', json_encode($templateContextParameters, JSON_THROW_ON_ERROR)],
533  ]);
534 
535  $sender_equals_reveiver = $usrId === $this->mailbox->getUsrId();
536  $is_sent_folder_of_sender = false;
537  if ($sender_equals_reveiver) {
538  $current_folder_id = $this->getSubjectSentFolderId();
539  $is_sent_folder_of_sender = $folderId === $current_folder_id;
540  }
541 
542  $raise_event = !$sender_equals_reveiver || !$is_sent_folder_of_sender;
543 
544  if ($raise_event) {
545  $this->event_handler->raise('Services/Mail', 'sentInternalMail', [
546  'id' => $nextId,
547  'subject' => $subject,
548  'body' => $message,
549  'from_usr_id' => $senderUsrId,
550  'to_usr_id' => $usrId,
551  'rcp_to' => $to,
552  'rcp_cc' => $cc,
553  'rcp_bcc' => $bcc,
554  ]);
555  }
556 
557  return $nextId;
558  }
int $user_id
replacePlaceholders(string $message, int $usrId=0)
$message
Definition: xapiexit.php:32
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
string[]$attachments
Returns
ilMailError[]
See also
ilMail::enqueue()

Definition at line 1087 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().

1089  : array {
1090  $internalMessageId = $this->saveInSentbox(
1091  $mail_data->getAttachments(),
1092  $mail_data->getTo(),
1093  $mail_data->getCc(),
1094  $mail_data->getBcc(),
1095  $mail_data->getSubject(),
1096  $mail_data->getMessage()
1097  );
1098  $mail_data = $mail_data->withInternalMailId($internalMessageId);
1099 
1100  if ($mail_data->getAttachments() !== []) {
1101  $this->mail_file_data->assignAttachmentsToDirectory($internalMessageId, $internalMessageId);
1102  $this->mail_file_data->saveFiles($internalMessageId, $mail_data->getAttachments());
1103  }
1104 
1105  $numberOfExternalAddresses = $this->getCountRecipients($mail_data->getTo(), $mail_data->getCc(), $mail_data->getBcc());
1106 
1107  if ($numberOfExternalAddresses > 0) {
1108  $externalMailRecipientsTo = $this->getEmailRecipients($mail_data->getTo());
1109  $externalMailRecipientsCc = $this->getEmailRecipients($mail_data->getCc());
1110  $externalMailRecipientsBcc = $this->getEmailRecipients($mail_data->getBcc());
1111 
1112  $this->logger->debug(
1113  "Parsed external email addresses from given recipients /" .
1114  " To: " . $externalMailRecipientsTo .
1115  " | CC: " . $externalMailRecipientsCc .
1116  " | BCC: " . $externalMailRecipientsBcc .
1117  " | Subject: " . $mail_data->getSubject()
1118  );
1119 
1120  $this->sendMimeMail(
1121  $externalMailRecipientsTo,
1122  $externalMailRecipientsCc,
1123  $externalMailRecipientsBcc,
1124  $mail_data->getSubject(),
1125  $mail_data->isUsePlaceholder() ?
1126  $this->replacePlaceholders($mail_data->getMessage(), 0) :
1127  $mail_data->getMessage(),
1128  $mail_data->getAttachments()
1129  );
1130  } else {
1131  $this->logger->debug('No external email addresses given in recipient string');
1132  }
1133 
1134  $errors = [];
1135 
1136  if (!$this->distributeMail($mail_data)) {
1137  $errors['mail_send_error'] = new ilMailError('mail_send_error');
1138  }
1139 
1140  if (!$this->getSaveInSentbox()) {
1141  $this->deleteMails([$internalMessageId]);
1142  }
1143 
1144  if ($this->isSystemMail()) {
1145  $random = new ilRandom();
1146  if ($random->int(0, 50) === 2) {
1148  $this->logger,
1149  $this->mail_file_data
1150  ))->run();
1151  }
1152  }
1153 
1154  return array_values($errors);
1155  }
Class ilMailError.
getEmailRecipients(string $recipients)
getCountRecipients(string $toRecipients, string $ccRecipients, string $bccRecipients, bool $onlyExternalAddresses=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)
replacePlaceholders(string $message, int $usrId=0)
getSaveInSentbox()
deleteMails(array $mailIds)
Wrapper for generation of random numbers, strings, bytes.
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

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

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

Referenced by distributeMail().

657  : void {
658  $to_recipients = array_map(
659  $this->createRecipient(...),
660  $to_usr_ids
661  );
662 
663  $this->sendChanneledMails(
664  $mail_data,
665  array_merge($to_recipients, $cc_bcc_recipients),
666  $mail_data->getMessage()
667  );
668  }
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

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

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

Referenced by distributeMail().

645  : void {
646  $this->sendChanneledMails(
647  $mail_data,
648  $recipients,
649  $this->replacePlaceholdersEmpty($mail_data->getMessage()),
650  );
651  }
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

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

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

Referenced by distributeMail().

630  : void {
631  foreach ($to_usr_ids as $user_id) {
632  $recipient = $this->createRecipient($user_id);
633 
634  $this->sendChanneledMails(
635  $mail_data,
636  [$recipient],
637  $this->replacePlaceholders($mail_data->getMessage(), $user_id),
638  );
639  }
640  }
sendChanneledMails(MailDeliveryData $mail_data, array $recipients, string $message)
int $user_id
replacePlaceholders(string $message, int $usrId=0)
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
string[]$attachments

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

Referenced by delegateExternalEmails(), and sendMail().

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

◆ setMailOptionsByUserIdMap()

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

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

1463  : void
1464  {
1465  $this->mail_options_by_usr_id_map = $mailOptionsByUsrIdMap;
1466  }

◆ setSaveInSentbox()

ilMail::setSaveInSentbox ( bool  $saveInSentbox)

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

Referenced by __construct().

146  : void
147  {
148  $this->save_in_sentbox = $saveInSentbox;
149  }
+ Here is the caller graph for this function:

◆ setUserInstanceById()

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

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

1446  : void
1447  {
1448  $this->user_instances_by_id_map = $userInstanceByIdMap;
1449  }

◆ 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
string[]$a_attachments

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

470  : int {
471  $this->db->update(
472  $this->table_mail,
473  [
474  'folder_id' => ['integer', $a_folder_id],
475  'attachments' => ['clob', serialize($a_attachments)],
476  'send_time' => ['timestamp', date('Y-m-d H:i:s')],
477  'rcp_to' => ['clob', $a_rcp_to],
478  'rcp_cc' => ['clob', $a_rcp_cc],
479  'rcp_bcc' => ['clob', $a_rcp_bcc],
480  'm_status' => ['text', 'read'],
481  'm_subject' => ['text', $a_m_subject],
482  'm_message' => ['clob', $a_m_message],
483  'use_placeholders' => ['integer', (int) $a_use_placeholders],
484  'tpl_ctx_id' => ['text', $a_tpl_context_id],
485  'tpl_ctx_params' => ['blob', json_encode($a_tpl_context_params, JSON_THROW_ON_ERROR)],
486  ],
487  [
488  'mail_id' => ['integer', $a_draft_id],
489  ]
490  );
491 
492  return $a_draft_id;
493  }

◆ validateRecipients()

ilMail::validateRecipients ( string  $to,
string  $cc,
string  $bcc 
)
Returns
ilMailError[]

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

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

Referenced by enqueue().

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

◆ withContextId()

ilMail::withContextId ( string  $contextId)

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

111  : self
112  {
113  $clone = clone $this;
114 
115  $clone->context_id = $contextId;
116 
117  return $clone;
118  }

◆ withContextParameters()

ilMail::withContextParameters ( array  $parameters)

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

120  : self
121  {
122  $clone = clone $this;
123 
124  $clone->context_parameters = $parameters;
125 
126  return $clone;
127  }

Field Documentation

◆ $append_installation_signature

bool ilMail::$append_installation_signature = false
private

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

Referenced by appendInstallationSignature().

◆ $context_id

string ilMail::$context_id = null
private

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

◆ $context_parameters

array ilMail::$context_parameters = []
private

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

◆ $legal_documents

readonly Conductor ilMail::$legal_documents
private

Definition at line 53 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 48 of file class.ilMail.php.

◆ $max_recipient_character_length

int ilMail::$max_recipient_character_length = 998
private

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

◆ $save_in_sentbox

bool ilMail::$save_in_sentbox
private

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

Referenced by getSaveInSentbox().

◆ $table_mail

string ilMail::$table_mail
private

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

◆ $table_mail_saved

string ilMail::$table_mail_saved
private

Definition at line 38 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 51 of file class.ilMail.php.

◆ ILIAS_HOST

const ilMail::ILIAS_HOST = 'ilias'

◆ PROP_CONTEXT_SUBJECT_PREFIX


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