4 require_once
'Services/User/classes/class.ilObjUser.php';
5 require_once
'Services/Mail/exceptions/class.ilMailException.php';
94 require_once
'Services/Mail/classes/class.ilFileDataMail.php';
95 require_once
'Services/Mail/classes/class.ilMailOptions.php';
113 $this->lng = $DIC->language();
114 $this->db = $DIC->database();
116 $this->lng->loadLanguageModule(
'mail');
118 $this->table_mail =
'mail';
119 $this->table_mail_saved =
'mail_saved';
121 $this->user_id = $a_user_id;
125 $this->mailbox =
new ilMailbox($this->user_id);
137 $clone = clone $this;
150 $clone = clone $this;
152 $clone->contextParameters = $parameters;
162 return $this->user_id == ANONYMOUS_USER_ID;
175 if (isset($this->properties[
$name])) {
176 return $this->properties[
$name];
179 if ($name ==
'mlists') {
180 if (is_object($DIC->user())) {
181 require_once
'Services/Contact/classes/class.ilMailingLists.php';
183 return $this->properties[
$name];
193 public function existsRecipient(
string $newRecipient,
string $existingRecipients) : bool
195 $newAddresses = new \ilMailAddressListImpl($this->
parseAddresses($newRecipient));
196 $addresses = new \ilMailAddressListImpl($this->
parseAddresses($existingRecipients));
198 $list = new \ilMailDiffAddressList($newAddresses, $addresses);
200 $diffedAddresses =
$list->value();
202 return count($diffedAddresses) === 0;
212 $this->soap_enabled = (bool) $a_status;
222 if (!extension_loaded(
'curl') || !$DIC->settings()->get(
'soap_user_administration')) {
238 $this->save_in_sentbox = (bool) $a_save_in_sentbox;
254 require_once
'Services/Mail/classes/class.ilMailGlobalServices.php';
276 $a_recipients = trim($a_recipients);
277 if (!strlen($a_recipients)) {
278 return $this->lng->txt(
'not_available');
283 $recipients = array_filter(array_map(
'trim', explode(
',', $a_recipients)));
284 foreach ($recipients as $recipient) {
288 if ($pp ==
'y' || ($pp ==
'g' && !$DIC->user()->isAnonymous())) {
289 $user = self::getCachedUserInstance($usr_id);
290 $names[] =
$user->getFullname() .
' [' . $recipient .
']';
295 $names[] = $recipient;
298 return implode(
', ', $names);
307 $this->db->setLimit(1);
309 $res = $this->db->queryF(
311 SELECT b.* FROM {$this->table_mail} a 312 INNER JOIN {$this->table_mail} b ON b.folder_id = a.folder_id 313 AND b.user_id = a.user_id AND b.send_time > a.send_time 314 WHERE a.user_id = %s AND a.mail_id = %s ORDER BY b.send_time ASC",
315 array(
'integer',
'integer'),
316 array($this->user_id, $a_mail_id)
330 $this->db->setLimit(1);
332 $res = $this->db->queryF(
334 SELECT b.* FROM {$this->table_mail} a 335 INNER JOIN {$this->table_mail} b ON b.folder_id = a.folder_id 336 AND b.user_id = a.user_id AND b.send_time < a.send_time 337 WHERE a.user_id = %s AND a.mail_id = %s ORDER BY b.send_time DESC",
338 array(
'integer',
'integer'),
339 array($this->user_id, $a_mail_id)
357 SELECT sender_id, m_subject, mail_id, m_status, send_time FROM {$this->table_mail} 358 LEFT JOIN object_data ON obj_id = sender_id 359 WHERE user_id = %s AND folder_id = %s 360 AND ((sender_id > 0 AND sender_id IS NOT NULL AND obj_id IS NOT NULL) OR (sender_id = 0 OR sender_id IS NULL)) ";
362 if (isset($filter[
'status']) && strlen($filter[
'status']) > 0) {
363 $query .=
' AND m_status = ' . $this->db->quote($filter[
'status'],
'text');
366 if (isset($filter[
'type']) && strlen($filter[
'type']) > 0) {
367 $query .=
' AND ' . $this->db->like(
'm_type',
'text',
'%%:"' . $filter[
'type'] .
'"%%',
false);
370 $query .=
" ORDER BY send_time DESC";
372 $res = $this->db->queryF(
374 array(
'integer',
'integer'),
375 array($this->user_id, $a_folder_id)
378 while (
$row = $this->db->fetchAssoc(
$res)) {
391 $res = $this->db->queryF(
393 SELECT COUNT(*) FROM {$this->table_mail} 394 WHERE user_id = %s AND folder_id = %s",
395 array(
'integer',
'integer'),
396 array($this->user_id, $a_folder_id)
399 return $this->db->numRows(
$res);
426 $res = $this->db->queryF(
428 SELECT * FROM {$this->table_mail} 429 WHERE user_id = %s AND mail_id = %s",
430 array(
'integer',
'integer'),
431 array($this->user_id, $a_mail_id)
446 $data_types = array();
448 $query =
"UPDATE {$this->table_mail} SET m_status = %s WHERE user_id = %s ";
449 array_push($data_types,
'text',
'integer');
450 array_push(
$data,
'read', $this->user_id);
452 if (count($a_mail_ids) > 0) {
453 $in =
'mail_id IN (';
455 foreach ($a_mail_ids as $a_mail_id) {
456 array_push(
$data, $a_mail_id);
457 array_push($data_types,
'integer');
470 $this->db->manipulateF(
$query, $data_types,
$data);
482 $data_types = array();
484 $query =
"UPDATE {$this->table_mail} SET m_status = %s WHERE user_id = %s ";
485 array_push($data_types,
'text',
'integer');
486 array_push(
$data,
'unread', $this->user_id);
488 if (count($a_mail_ids) > 0) {
489 $in =
'mail_id IN (';
491 foreach ($a_mail_ids as $a_mail_id) {
492 array_push(
$data, $a_mail_id);
493 array_push($data_types,
'integer');
506 $this->db->manipulateF(
$query, $data_types,
$data);
521 $mailIds = array_filter(array_map(
'intval', $mailIds));
523 if (0 === count($mailIds)) {
528 UPDATE {$this->table_mail} 529 INNER JOIN mail_obj_data 530 ON mail_obj_data.obj_id = %s AND mail_obj_data.user_id = %s 531 SET {$this->table_mail}.folder_id = mail_obj_data.obj_id 532 WHERE {$this->table_mail}.user_id = %s 534 array_push($dataTypes,
'integer',
'integer',
'integer');
535 array_push(
$values, $folderId, $this->user_id, $this->user_id);
537 $in =
'mail_id IN (';
539 foreach ($mailIds as $mailId) {
541 array_push($dataTypes,
'integer');
553 $affectedRows = $this->db->manipulateF(
$query, $dataTypes,
$values);
555 return $affectedRows > 0;
564 $mailIds = array_filter(array_map(
'intval', $mailIds));
565 foreach ($mailIds as
$id) {
566 $this->db->manipulateF(
568 DELETE FROM {$this->table_mail} WHERE user_id = %s AND mail_id = %s",
569 array(
'integer',
'integer'),
570 array($this->user_id, $id)
572 $this->mfile->deassignAttachmentFromDirectory($id);
584 if (!is_array($a_row) || empty($a_row)) {
588 $a_row[
'attachments'] = unserialize(stripslashes($a_row[
'attachments']));
589 $a_row[
'm_type'] = unserialize(stripslashes($a_row[
'm_type']));
590 $a_row[
'tpl_ctx_params'] = (array) (@json_decode($a_row[
'tpl_ctx_params'],
true));
602 $next_id = $this->db->nextId($this->table_mail);
603 $this->db->insert($this->table_mail, array(
604 'mail_id' => array(
'integer', $next_id),
605 'user_id' => array(
'integer', $usrId),
606 'folder_id' => array(
'integer', $folderId),
607 'sender_id' => array(
'integer', $usrId)
624 $a_use_placeholders = 0,
625 $a_tpl_context_id = null,
626 $a_tpl_context_params = array()
631 'folder_id' => array(
'integer', $a_folder_id),
632 'attachments' => array(
'clob', serialize($a_attachments)),
633 'send_time' => array(
'timestamp', date(
'Y-m-d H:i:s', time())),
634 'rcp_to' => array(
'clob', $a_rcp_to),
635 'rcp_cc' => array(
'clob', $a_rcp_cc),
636 'rcp_bcc' => array(
'clob', $a_rcp_bcc),
637 'm_status' => array(
'text',
'read'),
638 'm_type' => array(
'text', serialize($a_m_type)),
639 'm_email' => array(
'integer', $a_m_email),
640 'm_subject' => array(
'text', $a_m_subject),
641 'm_message' => array(
'clob', $a_m_message),
642 'use_placeholders' => array(
'integer', $a_use_placeholders),
643 'tpl_ctx_id' => array(
'text', $a_tpl_context_id),
644 'tpl_ctx_params' => array(
'blob', @json_encode((array) $a_tpl_context_params))
647 'mail_id' => array(
'integer', $a_draft_id)
687 $a_use_placeholders = 0,
688 $a_tpl_context_id = null,
689 $a_tpl_context_params = array()
693 if ($a_use_placeholders) {
707 if (!$a_attachments) {
708 $a_attachments = null;
735 $nextId = $this->db->nextId($this->table_mail);
736 $this->db->insert($this->table_mail, array(
737 'mail_id' => array(
'integer', $nextId),
738 'user_id' => array(
'integer', $a_user_id),
739 'folder_id' => array(
'integer', $a_folder_id),
740 'sender_id' => array(
'integer', $a_sender_id),
741 'attachments' => array(
'clob', serialize($a_attachments)),
742 'send_time' => array(
'timestamp', date(
'Y-m-d H:i:s', time())),
743 'rcp_to' => array(
'clob', $a_rcp_to),
744 'rcp_cc' => array(
'clob', $a_rcp_cc),
745 'rcp_bcc' => array(
'clob', $a_rcp_bcc),
746 'm_status' => array(
'text', $a_status),
747 'm_type' => array(
'text', serialize($a_m_type)),
748 'm_email' => array(
'integer', $a_m_email),
749 'm_subject' => array(
'text', $a_m_subject),
750 'm_message' => array(
'clob', $a_m_message),
751 'tpl_ctx_id' => array(
'text', $a_tpl_context_id),
752 'tpl_ctx_params' => array(
'blob', @json_encode((array) $a_tpl_context_params))
755 $raiseEvent = (int) $a_user_id !== (
int) $this->mailbox->getUserId();
757 $raiseEvent = (int) $a_folder_id !== (
int) $this->mailbox->getSentFolder();
761 $this->eventHandler->raise(
'Services/Mail',
'sentInternalMail', [
762 'id' => (
int) $nextId,
763 'subject' => (
string) $a_m_subject,
764 'body' => (
string) $a_m_message,
765 'from_usr_id' => (
int) $a_sender_id,
766 'to_usr_id' => (
int) $a_user_id,
767 'rcp_to' => (
string) $a_rcp_to,
768 'rcp_cc' => (
string) $a_rcp_cc,
769 'rcp_bcc' => (
string) $a_rcp_bcc,
770 'type' => (array) $a_m_type,
786 if ($this->contextId) {
792 $user = $a_user_id > 0 ? self::getCachedUserInstance($a_user_id) : null;
795 $a_message = $processor->resolve(
$user, $this->contextParameters, $replace_empty);
816 protected function distributeMail($a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_subject, $a_message, $a_attachments, $sent_mail_id,
$a_type, $a_action, $a_use_placeholders = 0)
818 require_once
'Services/Mail/classes/class.ilMailbox.php';
819 require_once
'Services/User/classes/class.ilObjUser.php';
822 if (!$a_use_placeholders) {
823 $rcp_ids = $this->
getUserIds(array($a_rcp_to, $a_rcp_cc, $a_rcp_bcc));
826 "Parsed TO/CC/BCC user ids from given recipients: %s",
827 implode(
', ', $rcp_ids)
832 foreach ($rcp_ids as
$id) {
835 $tmp_user = self::getCachedUserInstance($id);
836 $user_is_active = $tmp_user->getActive();
837 $user_can_read_internal_mails = !$tmp_user->hasToAcceptTermsOfService() && $tmp_user->checkTimeLimit();
839 if (in_array(
'system',
$a_type) && !$user_can_read_internal_mails) {
841 "Message is marked as 'system', skipped recipient with id %s (Accepted User Agreement:%s|Expired Account:%s)",
843 var_export(!$tmp_user->hasToAcceptTermsOfService(), 1),
844 var_export(!$tmp_user->checkTimeLimit(), 1)
849 if ($user_is_active) {
850 if (!$user_can_read_internal_mails
854 $as_email = array_unique(array_merge($newEmailAddresses, $as_email));
858 "Recipient with id %s will only receive external emails sent to: %s",
860 implode(
', ', $newEmailAddresses)
865 "Recipient with id %s will additionally receive external emails sent to: %s",
867 implode(
', ', $newEmailAddresses)
873 $mbox->setUserId($id);
874 $inbox_id = $mbox->getInboxFolder();
892 if ($a_attachments) {
893 $this->mfile->assignAttachmentsToDirectory($mail_id, $sent_mail_id);
900 $as_email = array_values(array_unique($as_email));
901 if (count($as_email) == 1) {
902 $to[] = $as_email[0];
904 foreach ($as_email as
$email) {
909 if (count($to) > 0) {
910 $this->sendMimeMail(implode(
',', $to),
'', implode(
',', $bcc), $a_subject, $this->
formatLinebreakMessage($a_message), $a_attachments);
911 } elseif (count($bcc) > 0) {
912 $remainingAddresses =
'';
913 $maxRecipientCharacterLength = 998;
914 foreach ($bcc as $emailAddress) {
916 if (strlen($remainingAddresses) > 0) {
921 if ($recipientsLineLength >= $maxRecipientCharacterLength) {
931 $remainingAddresses =
'';
935 $remainingAddresses .= ($sep . $emailAddress);
938 if (
'' !== $remainingAddresses) {
950 $rcp_ids_replace = $this->
getUserIds(array($a_rcp_to));
951 $rcp_ids_no_replace = $this->
getUserIds(array($a_rcp_cc, $a_rcp_bcc));
954 "Parsed TO user ids from given recipients for serial letter notification: %s",
955 implode(
', ', $rcp_ids_replace)
958 "Parsed CC/BCC user ids from given recipients for serial letter notification: %s",
959 implode(
', ', $rcp_ids_no_replace)
963 $id_to_message_map = array();
965 foreach ($rcp_ids_replace as
$id) {
968 $tmp_user = self::getCachedUserInstance($id);
969 $user_is_active = $tmp_user->getActive();
970 $user_can_read_internal_mails = !$tmp_user->hasToAcceptTermsOfService() && $tmp_user->checkTimeLimit();
972 if (in_array(
'system',
$a_type) && !$user_can_read_internal_mails) {
974 "Message is marked as 'system', skipped recipient with id %s (Accepted User Agreement:%s|Expired Account:%s)",
976 var_export(!$tmp_user->hasToAcceptTermsOfService(), 1),
977 var_export(!$tmp_user->checkTimeLimit(), 1)
984 if ($user_is_active) {
985 if (!$user_can_read_internal_mails
992 "Recipient with id %s will only receive external emails sent to: %s",
994 implode(
', ', $as_email[$tmp_user->getId()])
999 "Recipient with id %s will additionally receive external emails sent to: %s",
1001 implode(
', ', $as_email[$tmp_user->getId()])
1007 $mbox->setUserId($id);
1008 $inbox_id = $mbox->getInboxFolder();
1021 $id_to_message_map[$id],
1026 if ($a_attachments) {
1027 $this->mfile->assignAttachmentsToDirectory($mail_id, $sent_mail_id);
1031 if (count($as_email)) {
1032 foreach ($as_email as $id => $emails) {
1033 if (0 == count($emails)) {
1037 $toEmailAddresses = implode(
',', $emails);
1038 $this->sendMimeMail($toEmailAddresses,
'',
'', $a_subject, $this->
formatLinebreakMessage($id_to_message_map[$id]), $a_attachments);
1042 $as_email = array();
1046 foreach ($rcp_ids_no_replace as $id) {
1049 $tmp_user = self::getCachedUserInstance($id);
1050 $user_is_active = $tmp_user->getActive();
1051 $user_can_read_internal_mails = !$tmp_user->hasToAcceptTermsOfService() && $tmp_user->checkTimeLimit();
1053 if ($user_is_active) {
1054 if (in_array(
'system',
$a_type) && !$user_can_read_internal_mails) {
1056 "Message is marked as 'system', skipped recipient with id %s (Accepted User Agreement:%s|Expired Account:%s)",
1058 var_export(!$tmp_user->hasToAcceptTermsOfService(), 1),
1059 var_export(!$tmp_user->checkTimeLimit(), 1)
1065 if (!$user_can_read_internal_mails
1069 $as_email = array_unique(array_merge($newEmailAddresses, $as_email));
1073 "Recipient with id %s will only receive external emails sent to: %s",
1075 implode(
', ', $newEmailAddresses)
1080 "Recipient with id %s will additionally receive external emails sent to: %s",
1082 implode(
', ', $newEmailAddresses)
1088 $mbox->setUserId($id);
1089 $inbox_id = $mbox->getInboxFolder();
1102 $cc_and_bcc_message,
1107 if ($a_attachments) {
1108 $this->mfile->assignAttachmentsToDirectory($mail_id, $sent_mail_id);
1112 if (count($as_email)) {
1113 $this->sendMimeMail(
'',
'', implode(
',', $as_email), $a_subject, $this->
formatLinebreakMessage($cc_and_bcc_message), $a_attachments);
1128 $joinedRecipients = implode(
',', array_filter(array_map(
'trim', $recipients)));
1131 foreach ($addresses as $address) {
1132 $addressType = $this->mailAddressTypeFactory->getByPrefix($address);
1133 $usrIds = array_merge($usrIds, $addressType->resolve());
1136 return array_unique($usrIds);
1146 protected function checkMail(
string $to,
string $cc,
string $bcc,
string $subject) : array
1151 $subject =>
'mail_add_subject',
1152 $to =>
'mail_add_recipient' 1153 ) as $string => $error) {
1154 if (0 === strlen($string)) {
1155 $errors[] = new \ilMailError($error);
1174 foreach ($addresses as $address) {
1175 $addressType = $this->mailAddressTypeFactory->getByPrefix($address);
1176 if (!$addressType->validate($this->user_id)) {
1177 $newErrors = $addressType->getErrors();
1182 $colonPosition = strpos($e->getMessage(),
':');
1183 throw new \ilMailException(
1184 ($colonPosition ===
false) ? $e->getMessage() : substr($e->getMessage(), $colonPosition + 2)
1218 $a_use_placeholders,
1219 $a_tpl_context_id = null,
1220 $a_tpl_ctx_params = array()
1222 if (!$a_attachments) {
1223 $a_attachments = null;
1240 if (!$a_m_message) {
1241 $a_m_message = null;
1243 if (!$a_use_placeholders) {
1244 $a_use_placeholders =
'0';
1248 $this->table_mail_saved,
1250 'user_id' => array(
'integer', $this->user_id)
1253 'attachments' => array(
'clob', serialize($a_attachments)),
1254 'rcp_to' => array(
'clob', $a_rcp_to),
1255 'rcp_cc' => array(
'clob', $a_rcp_cc),
1256 'rcp_bcc' => array(
'clob', $a_rcp_bcc),
1257 'm_type' => array(
'text', serialize($a_m_type)),
1258 'm_email' => array(
'integer', $a_m_email),
1259 'm_subject' => array(
'text', $a_m_subject),
1260 'm_message' => array(
'clob', $a_m_message),
1261 'use_placeholders' => array(
'integer', $a_use_placeholders),
1262 'tpl_ctx_id' => array(
'text', $a_tpl_context_id),
1263 'tpl_ctx_params' => array(
'blob', json_encode((array) $a_tpl_ctx_params))
1277 $res = $this->db->queryF(
1278 "SELECT * FROM {$this->table_mail_saved} WHERE user_id = %s",
1280 array($this->user_id)
1300 public function sendMail($a_rcp_to, $a_rcp_cc, $a_rcp_bc, $a_m_subject, $a_m_message, $a_attachment,
$a_type, $a_use_placeholders = 0) : array
1305 "New mail system task:" .
1306 " To: " . $a_rcp_to .
1307 " | CC: " . $a_rcp_cc .
1308 " | BCC: " . $a_rcp_bc .
1309 " | Subject: " . $a_m_subject
1312 if (in_array(
'system',
$a_type)) {
1316 if ($a_attachment && !$this->mfile->checkFilesExist($a_attachment)) {
1317 return [new \ilMailError(
'mail_attachment_file_not_exist', [$a_attachment])];
1320 $errors = $this->
checkMail((
string) $a_rcp_to, (
string) $a_rcp_cc, (
string) $a_rcp_bc, (
string) $a_m_subject);
1330 $rcp_to = $a_rcp_to;
1331 $rcp_cc = $a_rcp_cc;
1332 $rcp_bc = $a_rcp_bc;
1334 if (null === $rcp_cc) {
1338 if (null === $rcp_bc) {
1342 $numberOfExternalAddresses = $this->
getCountRecipients($rcp_to, $rcp_cc, $rcp_bc,
true);
1345 $numberOfExternalAddresses > 0 &&
1347 !$DIC->rbac()->system()->checkAccessOfUser($this->user_id,
'smtp_mail', $this->mail_obj_ref_id)
1349 return [new \ilMailError(
'mail_no_permissions_write_smtp')];
1353 $a_m_message .= self::_getInstallationSignature();
1356 $sent_id = $this->
saveInSentbox($a_attachment, $a_rcp_to, $a_rcp_cc, $a_rcp_bc,
$a_type, $a_m_subject, $a_m_message);
1358 if ($a_attachment) {
1359 $this->mfile->assignAttachmentsToDirectory($sent_id, $sent_id);
1360 $this->mfile->saveFiles($sent_id, $a_attachment);
1363 if ($numberOfExternalAddresses > 0) {
1369 "Parsed external email addresses from given recipients:" .
1370 " To: " . $externalMailRecipientsTo .
1371 " | CC: " . $externalMailRecipientsCc .
1372 " | BCC: " . $externalMailRecipientsBcc .
1373 " | Subject: " . $a_m_subject
1376 $this->sendMimeMail(
1377 $externalMailRecipientsTo,
1378 $externalMailRecipientsCc,
1379 $externalMailRecipientsBcc,
1389 if (in_array(
'system',
$a_type) && !$this->
distributeMail($rcp_to, $rcp_cc, $rcp_bc, $a_m_subject, $a_m_message, $a_attachment, $sent_id,
$a_type,
'system', $a_use_placeholders)) {
1390 return [new \ilMailError(
'mail_send_error')];
1393 if (in_array(
'normal',
$a_type) && !$this->
distributeMail($rcp_to, $rcp_cc, $rcp_bc, $a_m_subject, $a_m_message, $a_attachment, $sent_id,
$a_type,
'normal', $a_use_placeholders)) {
1394 return [new \ilMailError(
'mail_send_error')];
1422 return [new \ilMailError(
'mail_generic_rcp_error', [$e->getMessage()])];
1439 protected function saveInSentbox($a_attachment, $a_rcp_to, $a_rcp_cc, $a_rcp_bcc,
$a_type, $a_m_subject, $a_m_message)
1442 $this->mailbox->getSentFolder(),
1469 public function sendMimeMail($a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_m_subject, $a_m_message, $a_attachments, $a_no_soap =
false)
1471 require_once
'Services/Mail/classes/class.ilMimeMail.php';
1473 $a_m_subject = self::getSubjectPrefix() .
' ' . $a_m_subject;
1477 require_once
'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
1479 $soap_client->setResponseTimeout(5);
1480 $soap_client->enableWSDL(
true);
1481 $soap_client->init();
1483 $attachments = array();
1484 $a_attachments = $a_attachments ? $a_attachments : array();
1485 foreach ($a_attachments as $attachment) {
1486 $attachments[] = $this->mfile->getAbsoluteAttachmentPoolPathByFilename($attachment);
1490 $attachments = implode(
'#:#', $attachments);
1492 if (strlen($attachments)) {
1493 $attachments =
"#:#" . $attachments;
1496 $soap_client->call(
'sendMail', array(
1497 session_id() .
'::' .
$_COOKIE[
'ilClientId'],
1508 $senderFactory =
$GLOBALS[
"DIC"][
"mail.mime.sender.factory"];
1511 $mmail->From($senderFactory->getSenderByUsrId($this->user_id));
1512 $mmail->To($a_rcp_to);
1513 $mmail->Subject($a_m_subject);
1514 $mmail->Body($a_m_message);
1517 $mmail->Cc($a_rcp_cc);
1521 $mmail->Bcc($a_rcp_bcc);
1524 if (is_array($a_attachments)) {
1525 foreach ($a_attachments as $attachment) {
1526 $mmail->Attach($this->mfile->getAbsoluteAttachmentPoolPathByFilename($attachment),
'',
'inline', $attachment);
1541 $this->table_mail_saved,
1543 'attachments' => array(
'clob', serialize($a_attachments))
1546 'user_id' => array(
'integer', $this->user_id)
1561 if (strlen($addresses) > 0) {
1563 "Started parsing of recipient string: %s",
1568 $parser = $this->mailAddressParserFactory->getParser((
string) $addresses);
1569 $parsedAddresses =
$parser->parse();
1571 if (strlen($addresses) > 0) {
1573 "Parsed addresses: %s",
1575 return (
string) $address;
1576 }, $parsedAddresses))
1580 return $parsedAddresses;
1590 $addresses = new \ilMailAddressListImpl($this->
parseAddresses($recipients));
1591 if ($onlyExternalAddresses) {
1592 $addresses = new \ilMailOnlyExternalAddressList($addresses, self::ILIAS_HOST);
1595 return count($addresses->value());
1606 string $toRecipients,
1607 string $ccRecipients,
1608 string $bccRecipients,
1609 $onlyExternalAddresses =
true 1624 $addresses = new \ilMailOnlyExternalAddressList(
1629 $emailRecipients = array_map(
function (\
ilMailAddress $address) {
1630 return (
string) $address;
1631 }, $addresses->value());
1633 return implode(
',', $emailRecipients);
1646 require_once
'Services/Language/classes/class.ilLanguageFactory.php';
1650 $lang->loadLanguageModule(
'mail');
1653 $lang->txt(
'mail_auto_generated_info'),
1654 $DIC->settings()->get(
'inst_name',
'ILIAS 5'),
1663 public static function _getIliasMailerName()
1666 $senderFactory =
$GLOBALS[
"DIC"][
"mail.mime.sender.factory"];
1668 return $senderFactory->system()->getFromName();
1678 if (null === $a_flag) {
1693 $signature = $DIC->settings()->get(
'mail_system_sys_signature');
1696 $clientdirs = glob(ILIAS_WEB_DIR .
'/*', GLOB_ONLYDIR);
1697 if (is_array($clientdirs) && count($clientdirs) > 1) {
1698 $clientUrl .=
'/login.php?client_id=' . CLIENT_ID;
1701 $signature = str_ireplace(
'[CLIENT_NAME]', $DIC[
'ilClientIniFile']->readVariable(
'client',
'name'), $signature);
1702 $signature = str_ireplace(
'[CLIENT_DESC]', $DIC[
'ilClientIniFile']->readVariable(
'client',
'description'), $signature);
1703 $signature = str_ireplace(
'[CLIENT_URL]', $clientUrl, $signature);
1705 if (!preg_match(
'/^[\n\r]+/', $signature)) {
1706 $signature =
"\n" . $signature;
1720 $subjectPrefix = $DIC->settings()->get(
'mail_subject_prefix');
1721 if (
false === $subjectPrefix) {
1722 $subjectPrefix = self::MAIL_SUBJECT_PREFIX;
1725 return $subjectPrefix;
1737 $lang = ($a_language instanceof
ilLanguage) ? $a_language : $DIC->language();
1738 $lang->loadLanguageModule(
'mail');
1741 $gender = $gender ? $gender :
'n';
1744 if (!strlen(
$name[
'firstname'])) {
1745 return $lang->txt(
'mail_salutation_anonymous') .
',';
1749 $lang->txt(
'mail_salutation_' . $gender) .
' ' .
1750 (
$name[
'title'] ?
$name[
'title'] .
' ' :
'') .
1751 (
$name[
'firstname'] ?
$name[
'firstname'] .
' ' :
'') .
1752 $name[
'lastname'] .
',';
1761 if (isset(self::$userInstances[$a_usr_id])) {
1762 return self::$userInstances[$a_usr_id];
1765 self::$userInstances[$a_usr_id] =
new ilObjUser($a_usr_id);
1766 return self::$userInstances[$a_usr_id];
static _lookupName($a_user_id)
lookup user name
markRead(array $a_mail_ids)
Class ilMailOptions this class handles user mails.
getEmailRecipients(string $recipients)
if(isset($_REQUEST['delete'])) $list
getCountRecipients(string $toRecipients, string $ccRecipients, string $bccRecipients, $onlyExternalAddresses=true)
distributeMail($a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_subject, $a_message, $a_attachments, $sent_mail_id, $a_type, $a_action, $a_use_placeholders=0)
getNewDraftId($usrId, $folderId)
static getCachedUserInstance($a_usr_id)
checkMail(string $to, string $cc, string $bcc, string $subject)
static getTemplateContextById($a_id)
__get($name)
Magic interceptor method __get Used to include files / instantiate objects at runtime.
existsRecipient(string $newRecipient, string $existingRecipients)
if(!array_key_exists('StateId', $_REQUEST)) $id
static _lookupId($a_user_str)
Lookup id by login.
setSaveInSentbox($a_save_in_sentbox)
updateDraft( $a_folder_id, $a_attachments, $a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_m_type, $a_m_email, $a_m_subject, $a_m_message, $a_draft_id=0, $a_use_placeholders=0, $a_tpl_context_id=null, $a_tpl_context_params=array())
static _lookupGender($a_user_id)
Lookup gender.
deleteMailsOfFolder($a_folder_id)
static getExternalEmailsByUser(ilObjUser $user, ilMailOptions $mail_options=null)
withContextParameters(array $parameters)
const MAIL_SUBJECT_PREFIX
$mailAddressParserFactory
static _getLanguage($a_lang_key='')
Get langauge object.
Class ilMailRfc822AddressParserFactory.
foreach($_POST as $key=> $value) $res
withContextId(string $contextId)
$appendInstallationSignature
__construct( $a_user_id, ilMailAddressTypeFactory $mailAddressTypeFactory=null, ilMailRfc822AddressParserFactory $mailAddressParserFactory=null, \ilAppEventHandler $eventHandler=null)
getCountRecipient(string $recipients, $onlyExternalAddresses=true)
Mail Box class Base class for creating and handling mail boxes.
checkRecipients(string $recipients)
Check if recipients are valid.
countMailsOfFolder($a_folder_id)
Class ilMailTemplaceProcessor.
appendInstallationSignature($a_flag=null)
Setter/Getter for appending the installation signarue.
savePostData( $a_user_id, $a_attachments, $a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_m_type, $a_m_email, $a_m_subject, $a_m_message, $a_use_placeholders, $a_tpl_context_id=null, $a_tpl_ctx_params=array())
save post data in table public
getMailObjectReferenceId()
getMailsOfFolder($a_folder_id, $filter=array())
sendMail($a_rcp_to, $a_rcp_cc, $a_rcp_bc, $a_m_subject, $a_m_message, $a_attachment, $a_type, $a_use_placeholders=0)
Should be used to send notifcations over the internal or external mail channel.
validateRecipients(string $to, string $cc, string $bcc)
if(php_sapi_name() !='cli') $in
formatLinebreakMessage($a_message)
replacePlaceholders($a_message, $a_user_id=0, $replace_empty=true)
static _lookupPref($a_usr_id, $a_keyword)
deleteMails(array $mailIds)
static _getAutoGeneratedMessageString(ilLanguage $lang=null)
Get auto generated info string.
static getMailObjectRefId()
Determines the reference id of the mail object and stores this information in a local cache variable...
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
sendInternalMail( $a_folder_id, $a_sender_id, $a_attachments, $a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_status, $a_m_type, $a_m_email, $a_m_subject, $a_m_message, $a_user_id=0, $a_use_placeholders=0, $a_tpl_context_id=null, $a_tpl_context_params=array())
save mail in folder private
getUserIds(array $recipients)
static getLogger($a_component_id)
Get component logger.
formatNamesForOutput($a_recipients)
Prepends the fullname of each ILIAS login name (if user has a public profile) found in the passed str...
enableSOAP($a_status)
Define if external mails should be sent using SOAP client or not.
static getType()
Get context type.
static getSubjectPrefix()
Get text that will be prepended to auto generated mails.
markUnread(array $a_mail_ids)
Class ilMailAddressTypeFactory.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
moveMailsToFolder(array $mailIds, int $folderId)
readMailObjectReferenceId()
Read and set the mail object ref id (administration node)
getPreviousMail($a_mail_id)
saveInSentbox($a_attachment, $a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_type, $a_m_subject, $a_m_message)
Stores a message in the sent bod of the current user.
static _getInstallationSignature()
static getSalutation($a_usr_id, ilLanguage $a_language=null)
Class ilMailAddressListImpl.
parseAddresses($addresses)
Explode recipient string, allowed separators are ',' ';' ' ' Returns an array with recipient ilMailAd...
saveAttachments($a_attachments)