4 require_once
'Services/User/classes/class.ilObjUser.php';
5 require_once
'Services/Mail/exceptions/class.ilMailException.php';
117 public function __construct($a_user_id)
125 require_once
'Services/Mail/classes/class.ilFileDataMail.php';
126 require_once
'Services/Mail/classes/class.ilMailOptions.php';
128 $lng->loadLanguageModule(
"mail");
133 $this->table_mail =
'mail';
134 $this->table_mail_saved =
'mail_saved';
136 $this->user_id = $a_user_id;
151 public function __get($name)
161 if($name ==
'mlists')
163 if(is_object($ilUser))
165 require_once
'Services/Contact/classes/class.ilMailingLists.php';
180 foreach($recipients as $rcp)
182 if(substr($rcp->getMailbox(), 0, 1) !=
'#')
184 if(trim($rcp->getMailbox()) == trim($a_recipient) || trim($rcp->getMailbox() .
'@' . $rcp->getHost()) == trim($a_recipient))
189 else if(substr($rcp->getMailbox(), 0, 7) ==
'#il_ml_')
191 if(trim($rcp->getMailbox() .
'@' . $rcp->getHost()) == trim($a_recipient))
198 if(trim($rcp->getMailbox() .
'@' . $rcp->getHost()) == trim($a_recipient))
215 $this->soap_enabled = (bool)$a_status;
221 public function isSOAPEnabled()
226 if(!extension_loaded(
'curl') || !$ilSetting->get(
'soap_user_administration'))
244 $this->save_in_sentbox = (bool)$a_save_in_sentbox;
260 require_once
'Services/Mail/classes/class.ilMailGlobalServices.php';
278 public function formatNamesForOutput($a_recipients)
283 $a_recipients = trim($a_recipients);
284 if(!strlen($a_recipients))
286 return $this->lng->txt(
'not_available');
291 $recipients = array_filter(array_map(
'trim', explode(
',', $a_recipients)));
292 foreach($recipients as $recipient)
298 if($pp ==
'y' || ($pp ==
'g' && !$ilUser->isAnonymous()))
300 $user = self::getCachedUserInstance($usr_id);
301 $names[] = $user->getFullname() .
' [' . $recipient .
']';
309 return implode(
', ',
$names);
318 $this->db->setLimit(1);
320 $res = $this->db->queryF(
" 321 SELECT b.* FROM {$this->table_mail} a 322 INNER JOIN {$this->table_mail} b ON b.folder_id = a.folder_id 323 AND b.user_id = a.user_id AND b.send_time > a.send_time 324 WHERE a.user_id = %s AND a.mail_id = %s ORDER BY b.send_time ASC",
325 array(
'integer',
'integer'),
326 array($this->user_id, $a_mail_id)
340 $this->db->setLimit(1);
342 $res = $this->db->queryF(
" 343 SELECT b.* FROM {$this->table_mail} a 344 INNER JOIN {$this->table_mail} b ON b.folder_id = a.folder_id 345 AND b.user_id = a.user_id AND b.send_time < a.send_time 346 WHERE a.user_id = %s AND a.mail_id = %s ORDER BY b.send_time DESC",
347 array(
'integer',
'integer'),
348 array($this->user_id, $a_mail_id)
366 SELECT sender_id, m_subject, mail_id, m_status, send_time FROM {$this->table_mail} 367 LEFT JOIN object_data ON obj_id = sender_id 368 WHERE user_id = %s AND folder_id = %s 369 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)) ";
371 if(isset($filter[
'status']) && strlen($filter[
'status']) > 0)
373 $query .=
' AND m_status = ' . $this->db->quote($filter[
'status'],
'text');
376 if(isset($filter[
'type']) && strlen($filter[
'type']) > 0)
378 $query .=
' AND ' . $this->db->like(
'm_type',
'text',
'%%:"' . $filter[
'type'] .
'"%%',
false);
381 $query .=
" ORDER BY send_time DESC";
384 array(
'integer',
'integer'),
385 array($this->user_id, $a_folder_id)
388 while(
$row = $this->db->fetchAssoc(
$res))
402 $res = $this->db->queryF(
" 403 SELECT COUNT(*) FROM {$this->table_mail} 404 WHERE user_id = %s AND folder_id = %s",
405 array(
'integer',
'integer'),
406 array($this->user_id, $a_folder_id));
408 return $this->db->numRows(
$res);
437 $res = $this->db->queryF(
" 438 SELECT * FROM {$this->table_mail} 439 WHERE user_id = %s AND mail_id = %s",
440 array(
'integer',
'integer'),
441 array($this->user_id, $a_mail_id));
455 $data_types =
array();
457 $query =
"UPDATE {$this->table_mail} SET m_status = %s WHERE user_id = %s ";
458 array_push($data_types,
'text',
'integer');
459 array_push(
$data,
'read', $this->user_id);
461 if(count($a_mail_ids) > 0)
463 $in =
'mail_id IN (';
465 foreach($a_mail_ids as $a_mail_id)
467 array_push(
$data, $a_mail_id);
468 array_push($data_types,
'integer');
479 $this->db->manipulateF(
$query, $data_types,
$data);
491 $data_types =
array();
493 $query =
"UPDATE {$this->table_mail} SET m_status = %s WHERE user_id = %s ";
494 array_push($data_types,
'text',
'integer');
495 array_push(
$data,
'unread', $this->user_id);
497 if(count($a_mail_ids) > 0)
499 $in =
'mail_id IN (';
501 foreach($a_mail_ids as $a_mail_id)
503 array_push(
$data, $a_mail_id);
504 array_push($data_types,
'integer');
515 $this->db->manipulateF(
$query, $data_types,
$data);
528 $data_types =
array();
530 $query =
"UPDATE {$this->table_mail} SET folder_id = %s WHERE user_id = %s ";
531 array_push($data_types,
'text',
'integer');
532 array_push(
$data, $a_folder_id, $this->user_id);
534 if(count($a_mail_ids) > 0)
536 $in =
'mail_id IN (';
538 foreach($a_mail_ids as $a_mail_id)
540 array_push(
$data, $a_mail_id);
541 array_push($data_types,
'integer');
552 $this->db->manipulateF(
$query, $data_types,
$data);
563 foreach($a_mail_ids as $id)
565 $this->db->manipulateF(
" 566 DELETE FROM {$this->table_mail} 567 WHERE user_id = %s AND mail_id = %s ",
568 array(
'integer',
'integer'),
569 array($this->user_id, $id)
571 $this->mfile->deassignAttachmentFromDirectory($id);
583 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)
614 $a_folder_id, $a_attachments, $a_rcp_to, $a_rcp_cc, $a_rcp_bcc,
615 $a_m_type, $a_m_email, $a_m_subject, $a_m_message, $a_draft_id = 0,
616 $a_use_placeholders = 0, $a_tpl_context_id = null, $a_tpl_context_params =
array()
619 $this->db->update($this->table_mail,
621 'folder_id' =>
array(
'integer', $a_folder_id),
622 'attachments' =>
array(
'clob', serialize($a_attachments)),
623 'send_time' =>
array(
'timestamp',
date(
'Y-m-d H:i:s',
time())),
624 'rcp_to' =>
array(
'clob', $a_rcp_to),
625 'rcp_cc' =>
array(
'clob', $a_rcp_cc),
626 'rcp_bcc' =>
array(
'clob', $a_rcp_bcc),
627 'm_status' =>
array(
'text',
'read'),
628 'm_type' =>
array(
'text', serialize($a_m_type)),
629 'm_email' =>
array(
'integer', $a_m_email),
630 'm_subject' =>
array(
'text', $a_m_subject),
631 'm_message' =>
array(
'clob', $a_m_message),
632 'use_placeholders' =>
array(
'integer', $a_use_placeholders),
633 'tpl_ctx_id' =>
array(
'text', $a_tpl_context_id),
634 'tpl_ctx_params' =>
array(
'blob', @json_encode((
array)$a_tpl_context_params))
637 'mail_id' =>
array(
'integer', $a_draft_id)
665 $a_folder_id, $a_sender_id, $a_attachments, $a_rcp_to, $a_rcp_cc, $a_rcp_bcc,
666 $a_status, $a_m_type, $a_m_email, $a_m_subject, $a_m_message, $a_user_id = 0,
667 $a_use_placeholders = 0, $a_tpl_context_id = null, $a_tpl_context_params =
array()
672 if($a_use_placeholders)
677 if(!$a_user_id) $a_user_id =
'0';
678 if(!$a_folder_id) $a_folder_id =
'0';
679 if(!$a_sender_id) $a_sender_id = NULL;
680 if(!$a_attachments) $a_attachments = NULL;
681 if(!$a_rcp_to) $a_rcp_to = NULL;
682 if(!$a_rcp_cc) $a_rcp_cc = NULL;
683 if(!$a_rcp_bcc) $a_rcp_bcc = NULL;
684 if(!$a_status) $a_status = NULL;
685 if(!$a_m_type) $a_m_type = NULL;
686 if(!$a_m_email) $a_m_email = NULL;
687 if(!$a_m_subject) $a_m_subject = NULL;
688 if(!$a_m_message) $a_m_message = NULL;
690 $next_id = $this->db->nextId($this->table_mail);
691 $this->db->insert($this->table_mail,
array(
692 'mail_id' =>
array(
'integer', $next_id),
693 'user_id' =>
array(
'integer', $a_user_id),
694 'folder_id' =>
array(
'integer', $a_folder_id),
695 'sender_id' =>
array(
'integer', $a_sender_id),
696 'attachments' =>
array(
'clob', serialize($a_attachments)),
697 'send_time' =>
array(
'timestamp',
date(
'Y-m-d H:i:s',
time())),
698 'rcp_to' =>
array(
'clob', $a_rcp_to),
699 'rcp_cc' =>
array(
'clob', $a_rcp_cc),
700 'rcp_bcc' =>
array(
'clob', $a_rcp_bcc),
701 'm_status' =>
array(
'text', $a_status),
702 'm_type' =>
array(
'text', serialize($a_m_type)),
703 'm_email' =>
array(
'integer', $a_m_email),
704 'm_subject' =>
array(
'text', $a_m_subject),
705 'm_message' =>
array(
'clob', $a_m_message),
706 'tpl_ctx_id' =>
array(
'text', $a_tpl_context_id),
707 'tpl_ctx_params' =>
array(
'blob', @json_encode((
array)$a_tpl_context_params))
723 include_once
'Services/Mail/classes/class.ilMailFormCall.php';
727 require_once
'Services/Mail/classes/class.ilMailTemplateService.php';
732 require_once
'Services/Mail/classes/class.ilMailTemplateGenericContext.php';
736 $user = $a_user_id > 0 ? self::getCachedUserInstance($a_user_id) : null;
738 require_once
'Services/Mail/classes/class.ilMailTemplatePlaceholderResolver.php';
744 require_once
'./Services/Logging/classes/public/class.ilLoggerFactory.php';
764 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)
766 require_once
'Services/Mail/classes/class.ilMailbox.php';
767 require_once
'Services/User/classes/class.ilObjUser.php';
770 if(!$a_use_placeholders)
772 $rcp_ids = $this->
getUserIds(trim($a_rcp_to) .
',' . trim($a_rcp_cc) .
',' . trim($a_rcp_bcc));
775 "Parsed TO/CC/BCC user ids from given recipients: %s", implode(
', ', $rcp_ids)
780 foreach($rcp_ids as $id)
784 $tmp_user = self::getCachedUserInstance($id);
785 $user_is_active = $tmp_user->getActive();
786 $user_can_read_internal_mails = !$tmp_user->hasToAcceptTermsOfService() && $tmp_user->checkTimeLimit();
788 if(in_array(
'system',
$a_type) && !$user_can_read_internal_mails)
795 if(!$user_can_read_internal_mails || $tmp_mail_options->getIncomingType() == $this->mail_options->EMAIL)
797 $as_email[] = $tmp_user->getEmail();
801 if($tmp_mail_options->getIncomingType() == $this->mail_options->BOTH)
803 $as_email[] = $tmp_user->getEmail();
807 $mbox->setUserId($id);
808 $inbox_id = $mbox->getInboxFolder();
811 $inbox_id, $this->user_id, $a_attachments, $a_rcp_to, $a_rcp_cc,
'',
812 'unread',
$a_type, 0, $a_subject, $a_message, $id, 0
817 $this->mfile->assignAttachmentsToDirectory($mail_id, $sent_mail_id, $a_attachments);
824 if(count($as_email) == 1)
826 $to[] = $as_email[0];
830 foreach ($as_email as $email)
836 if(count($to) > 0 || count($bcc) > 0)
838 $this->
sendMimeMail(implode(
',', $to),
'', implode(
',', $bcc), $a_subject, $a_message, $a_attachments);
843 $rcp_ids_replace = $this->
getUserIds(trim($a_rcp_to));
844 $rcp_ids_no_replace = $this->
getUserIds(trim($a_rcp_cc).
','.trim($a_rcp_bcc));
847 "Parsed TO user ids from given recipients for serial letter notification: %s", implode(
', ', $rcp_ids_replace)
850 "Parsed CC/BCC user ids from given recipients for serial letter notification: %s", implode(
', ', $rcp_ids_no_replace)
854 $id_to_message_map =
array();
856 foreach($rcp_ids_replace as $id)
860 $tmp_user = self::getCachedUserInstance($id);
861 $user_is_active = $tmp_user->getActive();
862 $user_can_read_internal_mails = !$tmp_user->hasToAcceptTermsOfService() && $tmp_user->checkTimeLimit();
864 if(in_array(
'system',
$a_type) && !$user_can_read_internal_mails)
873 if(!$user_can_read_internal_mails || $tmp_mail_options->getIncomingType() == $this->mail_options->EMAIL)
875 $as_email[$tmp_user->getId()] = $tmp_user->getEmail();
879 if($tmp_mail_options->getIncomingType() == $this->mail_options->BOTH)
881 $as_email[$tmp_user->getId()] = $tmp_user->getEmail();
885 $mbox->setUserId($id);
886 $inbox_id = $mbox->getInboxFolder();
889 $inbox_id, $this->user_id, $a_attachments, $a_rcp_to, $a_rcp_cc,
'',
890 'unread',
$a_type, 0, $a_subject, $id_to_message_map[$id], $id, 0
895 $this->mfile->assignAttachmentsToDirectory($mail_id, $sent_mail_id, $a_attachments);
901 foreach($as_email as $id => $email)
903 $this->
sendMimeMail($email,
'',
'', $a_subject, $id_to_message_map[$id], $a_attachments);
911 foreach($rcp_ids_no_replace as $id)
915 $tmp_user = self::getCachedUserInstance($id);
916 $user_is_active = $tmp_user->getActive();
917 $user_can_read_internal_mails = !$tmp_user->hasToAcceptTermsOfService() && $tmp_user->checkTimeLimit();
921 if(in_array(
'system',
$a_type) && !$user_can_read_internal_mails)
926 if(!$user_can_read_internal_mails || $tmp_mail_options->getIncomingType() == $this->mail_options->EMAIL)
928 $as_email[] = $tmp_user->getEmail();
932 if($tmp_mail_options->getIncomingType() == $this->mail_options->BOTH)
934 $as_email[] = $tmp_user->getEmail();
938 $mbox->setUserId($id);
939 $inbox_id = $mbox->getInboxFolder();
942 $inbox_id, $this->user_id, $a_attachments, $a_rcp_to, $a_rcp_cc,
'',
943 'unread',
$a_type, 0, $a_subject, $cc_and_bcc_message, $id, 0
948 $this->mfile->assignAttachmentsToDirectory($mail_id, $sent_mail_id, $a_attachments);
954 $this->
sendMimeMail(
'',
'', implode(
',', $as_email), $a_subject, $cc_and_bcc_message, $a_attachments);
969 require_once
'Services/Mail/classes/Address/Type/class.ilMailAddressTypeFactory.php';
971 foreach($recipients as $recipient)
974 $usr_ids = array_merge($usr_ids, $address_type->resolve());
977 return array_unique($usr_ids);
989 protected function checkMail($a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_m_subject, $a_m_message,
$a_type)
993 $a_m_subject =>
array(
'mail_add_subject'),
994 $a_rcp_to =>
array(
'mail_add_recipient')
997 if(strlen($string) === 0)
1019 require_once
'Services/Mail/classes/Address/Type/class.ilMailAddressTypeFactory.php';
1021 foreach($recipients as $recipient)
1024 if(!$address_type->validate($this->user_id))
1032 $colon_pos = strpos($e->getMessage(),
':');
1033 throw new ilMailException(($colon_pos ===
false) ? $e->getMessage() : substr($e->getMessage(), $colon_pos + 2));
1057 $a_user_id, $a_attachments, $a_rcp_to, $a_rcp_cc, $a_rcp_bcc,
1058 $a_m_type, $a_m_email, $a_m_subject, $a_m_message,
1059 $a_use_placeholders, $a_tpl_context_id = null, $a_tpl_ctx_params =
array()
1062 if(!$a_attachments) $a_attachments = NULL;
1063 if(!$a_rcp_to) $a_rcp_to = NULL;
1064 if(!$a_rcp_cc) $a_rcp_cc = NULL;
1065 if(!$a_rcp_bcc) $a_rcp_bcc = NULL;
1066 if(!$a_m_type) $a_m_type = NULL;
1067 if(!$a_m_email) $a_m_email = NULL;
1068 if(!$a_m_message) $a_m_message = NULL;
1069 if(!$a_use_placeholders) $a_use_placeholders =
'0';
1072 $this->table_mail_saved,
1074 'user_id' =>
array(
'integer', $this->user_id)
1077 'attachments' =>
array(
'clob', serialize($a_attachments)),
1078 'rcp_to' =>
array(
'clob', $a_rcp_to),
1079 'rcp_cc' =>
array(
'clob', $a_rcp_cc),
1080 'rcp_bcc' =>
array(
'clob', $a_rcp_bcc),
1081 'm_type' =>
array(
'text', serialize($a_m_type)),
1082 'm_email' =>
array(
'integer', $a_m_email),
1083 'm_subject' =>
array(
'text', $a_m_subject),
1084 'm_message' =>
array(
'clob', $a_m_message),
1085 'use_placeholders' =>
array(
'integer', $a_use_placeholders),
1086 'tpl_ctx_id' =>
array(
'text', $a_tpl_context_id),
1087 'tpl_ctx_params' =>
array(
'blob', json_encode((
array)$a_tpl_ctx_params))
1101 $res = $this->db->queryF(
1102 "SELECT * FROM {$this->table_mail_saved} WHERE user_id = %s",
1104 array($this->user_id)
1124 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)
1132 "New mail system task:" .
1133 " To: " . $a_rcp_to .
1134 " | CC: " . $a_rcp_cc .
1135 " | BCC: " . $a_rcp_bc .
1136 " | Subject: " . $a_m_subject
1139 $this->mail_to_global_roles =
true;
1140 if($this->user_id != ANONYMOUS_USER_ID)
1142 $this->mail_to_global_roles = $rbacsystem->checkAccessOfUser($this->user_id,
'mail_to_global_roles', $this->mail_obj_ref_id);
1145 if(in_array(
'system',
$a_type))
1150 if($a_attachment && !$this->mfile->checkFilesExist($a_attachment))
1152 return array(
array(
'mail_attachment_file_not_exist', $a_attachment));
1167 $rcp_to = $a_rcp_to;
1168 $rcp_cc = $a_rcp_cc;
1169 $rcp_bc = $a_rcp_bc;
1174 $c_emails && $this->user_id != ANONYMOUS_USER_ID &&
1175 !$rbacsystem->checkAccessOfUser($this->user_id,
'smtp_mail', $this->mail_obj_ref_id)
1178 return array(
array(
'mail_no_permissions_write_smtp'));
1183 $a_m_message .= self::_getInstallationSignature();
1186 $sent_id = $this->
saveInSentbox($a_attachment,$a_rcp_to,$a_rcp_cc,$a_rcp_bc,
$a_type, $a_m_subject, $a_m_message);
1190 $this->mfile->assignAttachmentsToDirectory($sent_id, $sent_id);
1191 $this->mfile->saveFiles($sent_id, $a_attachment);
1201 "Parsed external mail addresses from given recipients:" .
1202 " To: " . $externalMailRecipientsTo .
1203 " | CC: " . $externalMailRecipientsCc .
1204 " | BCC: " . $externalMailRecipientsBcc .
1205 " | Subject: " . $a_m_subject
1209 $externalMailRecipientsTo,
1210 $externalMailRecipientsCc,
1211 $externalMailRecipientsBcc,
1223 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))
1228 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))
1263 return array(
array(
'mail_generic_rcp_error', $e->getMessage()));
1280 protected function saveInSentbox($a_attachment, $a_rcp_to, $a_rcp_cc, $a_rcp_bcc,
$a_type, $a_m_subject, $a_m_message)
1282 require_once
'Services/Mail/classes/class.ilMailbox.php';
1285 $sent_folder_id = $mbox->getSentFolder();
1288 $sent_folder_id, $this->user_id, $a_attachment,
1289 $a_rcp_to,$a_rcp_cc, $a_rcp_bcc,
1291 $a_m_subject, $a_m_message, $this->user_id, 0
1299 protected function getMimeMailSender()
1304 if($this->user_id && $this->user_id != ANONYMOUS_USER_ID)
1306 $email = $ilUser->getEmail();
1307 $fullname = $ilUser->getFullname();
1310 $user = self::getCachedUserInstance($this->user_id);
1311 $email = $user->getEmail();
1312 $fullname = $user->getFullname();
1315 $sender =
array($email, $fullname);
1319 $sender = self::getIliasMailerAddress();
1329 public static function getIliasMailerAddress()
1334 $no_reply_adress = trim($ilSetting->get(
'mail_external_sender_noreply'));
1335 if(strlen($no_reply_adress))
1337 if(strpos($no_reply_adress,
'@') ===
false)
1339 $no_reply_adress =
'noreply@' . $no_reply_adress;
1344 $no_reply_adress =
'noreply@' .
$_SERVER[
'SERVER_NAME'];
1347 $sender =
array($no_reply_adress, self::_getIliasMailerName());
1351 $sender =
array(
'noreply@' .
$_SERVER[
'SERVER_NAME'], self::_getIliasMailerName());
1369 public function sendMimeMail($a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_m_subject, $a_m_message, $a_attachments, $a_no_soap =
false)
1371 require_once
'Services/Mail/classes/class.ilMimeMail.php';
1373 $a_m_subject = self::getSubjectPrefix() .
' ' . $a_m_subject;
1374 $sender = $this->getMimeMailSender();
1377 if($this->isSOAPEnabled() && !$a_no_soap)
1379 require_once
'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
1381 $soap_client->setResponseTimeout(5);
1382 $soap_client->enableWSDL(
true);
1383 $soap_client->init();
1385 $attachments =
array();
1386 $a_attachments = $a_attachments ? $a_attachments :
array();
1387 foreach($a_attachments as $attachment)
1389 $attachments[] = $this->mfile->getAbsolutePath($attachment);
1393 $attachments = implode(
'#:#', $attachments);
1395 if(strlen($attachments))
1397 $attachments =
"#:#" . $attachments;
1400 $soap_client->call(
'sendMail',
array(
1401 session_id() .
'::' .
$_COOKIE[
'ilClientId'],
1405 is_array($sender) ? implode(
'#:#', $sender) : $sender,
1416 include_once
"Services/Mail/classes/class.ilMimeMail.php";
1419 $mmail->autoCheck(
false);
1420 $mmail->From($sender);
1421 $mmail->To($a_rcp_to);
1422 $mmail->Subject($a_m_subject);
1423 $mmail->Body($a_m_message);
1427 $mmail->Cc($a_rcp_cc);
1432 $mmail->Bcc($a_rcp_bcc);
1435 if(is_array($a_attachments))
1437 foreach($a_attachments as $attachment)
1439 $mmail->Attach($this->mfile->getAbsolutePath($attachment),
'',
'inline', $attachment);
1453 $this->db->update($this->table_mail_saved,
1455 'attachments' =>
array(
'clob', serialize($a_attachments))
1458 'user_id' =>
array(
'integer', $this->user_id)
1473 if(strlen($addresses) > 0)
1476 "Started parsing of recipient string: %s", $addresses
1480 require_once
'Services/Mail/classes/Address/Parser/class.ilMailRfc822AddressParserFactory.php';
1482 $parsedAddresses =
$parser->parse();
1484 if(strlen($addresses) > 0)
1487 "Parsed addresses: %s", implode(
',', array_map(
function(
ilMailAddress $address) {
1489 }, $parsedAddresses))
1493 return $parsedAddresses;
1506 foreach($recipients as $recipient)
1519 if($recipient->getHost() != self::ILIAS_HOST && substr($recipient->getMailbox(), 0, 1) !=
'#')
1557 foreach($recipients as $recipient)
1559 if(substr($recipient->getMailbox(), 0, 1) !=
'#' && $recipient->getHost() != self::ILIAS_HOST)
1567 $rcp[] = $recipient->getMailbox() .
'@' . $recipient->getHost();
1571 return implode(
',', $rcp);
1579 public static function _getAutoGeneratedMessageString(
ilLanguage $lang = null)
1588 require_once
'Services/Language/classes/class.ilLanguageFactory.php';
1592 $lang->loadLanguageModule(
'mail');
1595 $lang->txt(
'mail_auto_generated_info'),
1596 $ilSetting->get(
'inst_name',
'ILIAS 5'),
1605 public static function _getIliasMailerName()
1612 if(strlen($ilSetting->get(
'mail_system_sender_name')))
1614 return $ilSetting->get(
'mail_system_sender_name');
1616 else if(strlen($ilSetting->get(
'short_inst_name')))
1618 return $ilSetting->get(
'short_inst_name');
1631 if(null === $a_flag)
1643 public static function _getInstallationSignature()
1646 global $ilClientIniFile;
1648 $signature =
"\n\n* * * * *\n";
1650 $signature .= $ilClientIniFile->readVariable(
'client',
'name') .
"\n";
1651 if(strlen($desc = $ilClientIniFile->readVariable(
'client',
'description')))
1653 $signature .= $desc .
"\n";
1658 $clientdirs = glob(ILIAS_WEB_DIR .
'/*', GLOB_ONLYDIR);
1659 if(is_array($clientdirs) && count($clientdirs) > 1)
1661 $signature .=
'/login.php?client_id=' . CLIENT_ID;
1664 $signature .=
"\n\n";
1673 public static function getSubjectPrefix()
1678 return $ilSetting->get(
'mail_subject_prefix',
'');
1686 public static function getSalutation($a_usr_id,
ilLanguage $a_language = null)
1692 $lang->loadLanguageModule(
'mail');
1695 $gender = $gender ? $gender :
'n';
1698 if(!strlen($name[
'firstname']))
1700 return $lang->txt(
'mail_salutation_anonymous') .
',';
1704 $lang->txt(
'mail_salutation_' . $gender) .
' ' .
1705 ($name[
'title'] ? $name[
'title'] .
' ' :
'') .
1706 ($name[
'firstname'] ? $name[
'firstname'] .
' ' :
'') .
1707 $name[
'lastname'] .
',';
1716 if(isset(self::$userInstances[$a_usr_id]))
1718 return self::$userInstances[$a_usr_id];
1721 self::$userInstances[$a_usr_id] =
new ilObjUser($a_usr_id);
1722 return self::$userInstances[$a_usr_id];
static _lookupName($a_user_id)
lookup user name
checkMail($a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_m_subject, $a_m_message, $a_type)
markRead(array $a_mail_ids)
Class UserMail this class handles user mails.
deleteMails(array $a_mail_ids)
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)
Base class for ILIAS Exception handling.
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
getNewDraftId($usrId, $folderId)
static getCachedUserInstance($a_usr_id)
This class handles all operations on files (attachments) in directory ilias_data/mail.
static is_email($a_email)
This preg-based function checks whether an e-mail address is formally valid.
static getParser($a_address)
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)
getCountRecipient($a_recipients, $a_only_email=true)
getEmailRecipients($a_recipients)
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
static _getLanguage($a_lang_key='')
Get langauge object.
validateRecipients($a_rcp_to, $a_rcp_cc, $a_rcp_bc)
this class encapsulates the PHP mail() function.
$appendInstallationSignature
Mail Box class Base class for creating and handling mail boxes.
This class handles base functions for mail handling.
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
getCountRecipients($a_to, $a_cc, $a_bcc, $a_only_email=true)
countMailsOfFolder($a_folder_id)
existsRecipient($a_recipient, $a_existing_recipients)
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()
Create styles array
The data for the language used.
getMailsOfFolder($a_folder_id, $filter=array())
if(php_sapi_name() !='cli') $in
replacePlaceholders($a_message, $a_user_id=0, $replace_empty=true)
moveMailsToFolder(array $a_mail_ids, $a_folder_id)
static _lookupPref($a_usr_id, $a_keyword)
static getMailObjectRefId()
Determines the reference id of the mail object and stores this information in a local cache variable...
static getByPrefix(ilMailAddress $a_address)
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
static getLogger($a_component_id)
Get component logger.
enableSOAP($a_status)
Define if external mails should be sent using SOAP client or not.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
static getType()
Get context type.
sendMimeMail($a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_m_subject, $a_m_message, $a_attachments, $a_no_soap=false)
Send mime mail using class.ilMimeMail.php.
markUnread(array $a_mail_ids)
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.
checkRecipients($a_recipients)
Check if recipients are valid.
getUserIds($a_recipients)
parseAddresses($addresses)
Explode recipient string, allowed separators are ',' ';' ' ' Returns an array with recipient ilMailAd...
static getTemplateContextById($a_id)
saveAttachments($a_attachments)