ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilMail.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Services/User/classes/class.ilObjUser.php';
5require_once 'Services/Mail/exceptions/class.ilMailException.php';
6
66class ilMail
67{
69 const ILIAS_HOST = 'ilias';
70
72 protected $lng;
73
75 protected $db;
76
78 protected $mfile;
79
81 protected $mail_options;
82
84 public $user_id;
85
87 protected $table_mail;
88
91
93 protected $mail_data = array();
94
97
100
101 protected $soap_enabled = true;
104
109 protected $properties = array();
110
112 protected static $userInstances = array();
113
117 public function __construct($a_user_id)
118 {
123 global $lng, $ilDB;
124
125 require_once 'Services/Mail/classes/class.ilFileDataMail.php';
126 require_once 'Services/Mail/classes/class.ilMailOptions.php';
127
128 $lng->loadLanguageModule("mail");
129
130 $this->lng = $lng;
131 $this->db = $ilDB;
132
133 $this->table_mail = 'mail';
134 $this->table_mail_saved = 'mail_saved';
135
136 $this->user_id = $a_user_id;
137
138 $this->mfile = new ilFileDataMail($this->user_id);
139 $this->mail_options = new ilMailOptions($a_user_id);
140
141 $this->setSaveInSentbox(false);
143 }
144
151 public function __get($name)
152 {
154 global $ilUser;
155
156 if(isset($this->properties[$name]))
157 {
158 return $this->properties[$name];
159 }
160
161 if($name == 'mlists')
162 {
163 if(is_object($ilUser))
164 {
165 require_once 'Services/Contact/classes/class.ilMailingLists.php';
166 $this->properties[$name] = new ilMailingLists($ilUser);
167 return $this->properties[$name];
168 }
169 }
170 }
171
177 public function existsRecipient($a_recipient, $a_existing_recipients)
178 {
179 $recipients = $this->parseAddresses($a_existing_recipients);
180 foreach($recipients as $rcp)
181 {
182 if(substr($rcp->getMailbox(), 0, 1) != '#')
183 {
184 if(trim($rcp->getMailbox()) == trim($a_recipient) || trim($rcp->getMailbox() . '@' . $rcp->getHost()) == trim($a_recipient))
185 {
186 return true;
187 }
188 }
189 else if(substr($rcp->getMailbox(), 0, 7) == '#il_ml_')
190 {
191 if(trim($rcp->getMailbox() . '@' . $rcp->getHost()) == trim($a_recipient))
192 {
193 return true;
194 }
195 }
196 else
197 {
198 if(trim($rcp->getMailbox() . '@' . $rcp->getHost()) == trim($a_recipient))
199 {
200 return true;
201 }
202 }
203 }
204
205 return false;
206 }
207
213 public function enableSOAP($a_status)
214 {
215 $this->soap_enabled = (bool)$a_status;
216 }
217
221 public function isSOAPEnabled()
222 {
224 global $ilSetting;
225
226 if(!extension_loaded('curl') || !$ilSetting->get('soap_user_administration'))
227 {
228 return false;
229 }
230
232 {
233 return false;
234 }
235
236 return (bool)$this->soap_enabled;
237 }
238
242 public function setSaveInSentbox($a_save_in_sentbox)
243 {
244 $this->save_in_sentbox = (bool)$a_save_in_sentbox;
245 }
246
250 public function getSaveInSentbox()
251 {
252 return (bool)$this->save_in_sentbox;
253 }
254
258 protected function readMailObjectReferenceId()
259 {
260 require_once 'Services/Mail/classes/class.ilMailGlobalServices.php';
261 $this->mail_obj_ref_id = ilMailGlobalServices::getMailObjectRefId();
262 }
263
267 public function getMailObjectReferenceId()
268 {
270 }
271
278 public function formatNamesForOutput($a_recipients)
279 {
281 global $ilUser;
282
283 $a_recipients = trim($a_recipients);
284 if(!strlen($a_recipients))
285 {
286 return $this->lng->txt('not_available');
287 }
288
289 $names = array();
290
291 $recipients = array_filter(array_map('trim', explode(',', $a_recipients)));
292 foreach($recipients as $recipient)
293 {
294 $usr_id = ilObjUser::_lookupId($recipient);
295 if($usr_id > 0)
296 {
297 $pp = ilObjUser::_lookupPref($usr_id, 'public_profile');
298 if($pp == 'y' || ($pp == 'g' && !$ilUser->isAnonymous()))
299 {
300 $user = self::getCachedUserInstance($usr_id);
301 $names[] = $user->getFullname() . ' [' . $recipient . ']';
302 continue;
303 }
304 }
305
306 $names[] = $recipient;
307 }
308
309 return implode(', ', $names);
310 }
311
316 public function getPreviousMail($a_mail_id)
317 {
318 $this->db->setLimit(1);
319
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)
327 );
328
329 $this->mail_data = $this->fetchMailData($this->db->fetchAssoc($res));
330
331 return $this->mail_data;
332 }
333
338 public function getNextMail($a_mail_id)
339 {
340 $this->db->setLimit(1);
341
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)
349 );
350
351 $this->mail_data = $this->fetchMailData($this->db->fetchAssoc($res));
352
353 return $this->mail_data;
354 }
355
361 public function getMailsOfFolder($a_folder_id, $filter = array())
362 {
363 $output = array();
364
365 $query = "
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)) ";
370
371 if(isset($filter['status']) && strlen($filter['status']) > 0)
372 {
373 $query .= ' AND m_status = ' . $this->db->quote($filter['status'], 'text');
374 }
375
376 if(isset($filter['type']) && strlen($filter['type']) > 0)
377 {
378 $query .= ' AND ' . $this->db->like('m_type', 'text', '%%:"' . $filter['type'] . '"%%', false);
379 }
380
381 $query .= " ORDER BY send_time DESC";
382
383 $res = $this->db->queryF($query,
384 array('integer', 'integer'),
385 array($this->user_id, $a_folder_id)
386 );
387
388 while($row = $this->db->fetchAssoc($res))
389 {
390 $output[] = $this->fetchMailData($row);
391 }
392
393 return $output;
394 }
395
400 public function countMailsOfFolder($a_folder_id)
401 {
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));
407
408 return $this->db->numRows($res);
409 }
410
415 public function deleteMailsOfFolder($a_folder_id)
416 {
417 if($a_folder_id)
418 {
419 $mails = $this->getMailsOfFolder($a_folder_id);
420 foreach((array)$mails as $mail_data)
421 {
422 $this->deleteMails(array($mail_data['mail_id']));
423 }
424
425 return true;
426 }
427
428 return false;
429 }
430
435 public function getMail($a_mail_id)
436 {
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));
442
443 $this->mail_data = $this->fetchMailData($this->db->fetchAssoc($res));
444
445 return $this->mail_data;
446 }
447
452 public function markRead(array $a_mail_ids)
453 {
454 $data = array();
455 $data_types = array();
456
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);
460
461 if(count($a_mail_ids) > 0)
462 {
463 $in = 'mail_id IN (';
464 $counter = 0;
465 foreach($a_mail_ids as $a_mail_id)
466 {
467 array_push($data, $a_mail_id);
468 array_push($data_types, 'integer');
469
470 if($counter > 0) $in .= ',';
471 $in .= '%s';
472 ++$counter;
473 }
474 $in .= ')';
475
476 $query .= ' AND ' . $in;
477 }
478
479 $this->db->manipulateF($query, $data_types, $data);
480
481 return true;
482 }
483
488 public function markUnread(array $a_mail_ids)
489 {
490 $data = array();
491 $data_types = array();
492
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);
496
497 if(count($a_mail_ids) > 0)
498 {
499 $in = 'mail_id IN (';
500 $counter = 0;
501 foreach($a_mail_ids as $a_mail_id)
502 {
503 array_push($data, $a_mail_id);
504 array_push($data_types, 'integer');
505
506 if($counter > 0) $in .= ',';
507 $in .= '%s';
508 ++$counter;
509 }
510 $in .= ')';
511
512 $query .= ' AND '.$in;
513 }
514
515 $this->db->manipulateF($query, $data_types, $data);
516
517 return true;
518 }
519
525 public function moveMailsToFolder(array $a_mail_ids, $a_folder_id)
526 {
527 $data = array();
528 $data_types = array();
529
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);
533
534 if(count($a_mail_ids) > 0)
535 {
536 $in = 'mail_id IN (';
537 $counter = 0;
538 foreach($a_mail_ids as $a_mail_id)
539 {
540 array_push($data, $a_mail_id);
541 array_push($data_types, 'integer');
542
543 if($counter > 0) $in .= ',';
544 $in .= '%s';
545 ++$counter;
546 }
547 $in .= ')';
548
549 $query .= ' AND '.$in;
550 }
551
552 $this->db->manipulateF($query, $data_types, $data);
553
554 return true;
555 }
556
561 public function deleteMails(array $a_mail_ids)
562 {
563 foreach($a_mail_ids as $id)
564 {
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)
570 );
571 $this->mfile->deassignAttachmentFromDirectory($id);
572 }
573
574 return true;
575 }
576
581 protected function fetchMailData($a_row)
582 {
583 if(!is_array($a_row) || empty($a_row))
584 {
585 return null;
586 }
587
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));
591
592 return $a_row;
593 }
594
600 public function getNewDraftId($usrId, $folderId)
601 {
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)
608 ));
609
610 return $next_id;
611 }
612
613 public function updateDraft(
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()
617 )
618 {
619 $this->db->update($this->table_mail,
620 array(
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))
635 ),
636 array(
637 'mail_id' => array('integer', $a_draft_id)
638 )
639 );
640
641 return $a_draft_id;
642 }
643
664 public function sendInternalMail(
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()
668 )
669 {
670 $a_user_id = $a_user_id ? $a_user_id : $this->user_id;
671
672 if($a_use_placeholders)
673 {
674 $a_m_message = $this->replacePlaceholders($a_m_message, $a_user_id);
675 }
676
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;
689
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))
708 ));
709
710 return $next_id;
711 }
712
719 protected function replacePlaceholders($a_message, $a_user_id = 0, $replace_empty = true)
720 {
721 try
722 {
723 include_once 'Services/Mail/classes/class.ilMailFormCall.php';
724
726 {
727 require_once 'Services/Mail/classes/class.ilMailTemplateService.php';
729 }
730 else
731 {
732 require_once 'Services/Mail/classes/class.ilMailTemplateGenericContext.php';
733 $context = new ilMailTemplateGenericContext();
734 }
735
736 $user = $a_user_id > 0 ? self::getCachedUserInstance($a_user_id) : null;
737
738 require_once 'Services/Mail/classes/class.ilMailTemplatePlaceholderResolver.php';
739 $processor = new ilMailTemplatePlaceholderResolver($context, $a_message);
740 $a_message = $processor->resolve($user, ilMailFormCall::getContextParameters(), $replace_empty);
741 }
742 catch(Exception $e)
743 {
744 require_once './Services/Logging/classes/public/class.ilLoggerFactory.php';
745 ilLoggerFactory::getLogger('mail')->error(__METHOD__ . ' has been called with invalid context.');
746 }
747
748 return $a_message;
749 }
750
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)
765 {
766 require_once 'Services/Mail/classes/class.ilMailbox.php';
767 require_once 'Services/User/classes/class.ilObjUser.php';
768
769 $mbox = new ilMailbox();
770 if(!$a_use_placeholders)
771 {
772 $rcp_ids = $this->getUserIds(trim($a_rcp_to) . ',' . trim($a_rcp_cc) . ',' . trim($a_rcp_bcc));
773
774 ilLoggerFactory::getLogger('mail')->debug(sprintf(
775 "Parsed TO/CC/BCC user ids from given recipients: %s", implode(', ', $rcp_ids)
776 ));
777
778 $as_email = array();
779
780 foreach($rcp_ids as $id)
781 {
782 $tmp_mail_options = new ilMailOptions($id);
783
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();
787
788 if(in_array('system', $a_type) && !$user_can_read_internal_mails)
789 {
790 continue;
791 }
792
793 if($user_is_active)
794 {
795 if(!$user_can_read_internal_mails || $tmp_mail_options->getIncomingType() == $this->mail_options->EMAIL)
796 {
797 $as_email[] = $tmp_user->getEmail();
798 continue;
799 }
800
801 if($tmp_mail_options->getIncomingType() == $this->mail_options->BOTH)
802 {
803 $as_email[] = $tmp_user->getEmail();
804 }
805 }
806
807 $mbox->setUserId($id);
808 $inbox_id = $mbox->getInboxFolder();
809
810 $mail_id = $this->sendInternalMail(
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
813 );
814
815 if($a_attachments)
816 {
817 $this->mfile->assignAttachmentsToDirectory($mail_id, $sent_mail_id, $a_attachments);
818 }
819 }
820
821 $to = array();
822 $bcc = array();
823
824 if(count($as_email) == 1)
825 {
826 $to[] = $as_email[0];
827 }
828 else
829 {
830 foreach ($as_email as $email)
831 {
832 $bcc[] = $email;
833 }
834 }
835
836 if(count($to) > 0 || count($bcc) > 0)
837 {
838 $this->sendMimeMail(implode(',', $to), '', implode(',', $bcc), $a_subject, $a_message, $a_attachments);
839 }
840 }
841 else
842 {
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));
845
846 ilLoggerFactory::getLogger('mail')->debug(sprintf(
847 "Parsed TO user ids from given recipients for serial letter notification: %s", implode(', ', $rcp_ids_replace)
848 ));
849 ilLoggerFactory::getLogger('mail')->debug(sprintf(
850 "Parsed CC/BCC user ids from given recipients for serial letter notification: %s", implode(', ', $rcp_ids_no_replace)
851 ));
852
853 $as_email = array();
854 $id_to_message_map = array();
855
856 foreach($rcp_ids_replace as $id)
857 {
858 $tmp_mail_options = new ilMailOptions($id);
859
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();
863
864 if(in_array('system', $a_type) && !$user_can_read_internal_mails)
865 {
866 continue;
867 }
868
869 $id_to_message_map[$id] = $this->replacePlaceholders($a_message, $id);
870
871 if($user_is_active)
872 {
873 if(!$user_can_read_internal_mails || $tmp_mail_options->getIncomingType() == $this->mail_options->EMAIL)
874 {
875 $as_email[$tmp_user->getId()] = $tmp_user->getEmail();
876 continue;
877 }
878
879 if($tmp_mail_options->getIncomingType() == $this->mail_options->BOTH)
880 {
881 $as_email[$tmp_user->getId()] = $tmp_user->getEmail();
882 }
883 }
884
885 $mbox->setUserId($id);
886 $inbox_id = $mbox->getInboxFolder();
887
888 $mail_id = $this->sendInternalMail(
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
891 );
892
893 if($a_attachments)
894 {
895 $this->mfile->assignAttachmentsToDirectory($mail_id, $sent_mail_id, $a_attachments);
896 }
897 }
898
899 if(count($as_email))
900 {
901 foreach($as_email as $id => $email)
902 {
903 $this->sendMimeMail($email, '', '', $a_subject, $id_to_message_map[$id], $a_attachments);
904 }
905 }
906
907 $as_email = array();
908
909 $cc_and_bcc_message = $this->replacePlaceholders($a_message, 0, false);
910
911 foreach($rcp_ids_no_replace as $id)
912 {
913 $tmp_mail_options = new ilMailOptions($id);
914
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();
918
919 if($user_is_active)
920 {
921 if(in_array('system', $a_type) && !$user_can_read_internal_mails)
922 {
923 continue;
924 }
925
926 if(!$user_can_read_internal_mails || $tmp_mail_options->getIncomingType() == $this->mail_options->EMAIL)
927 {
928 $as_email[] = $tmp_user->getEmail();
929 continue;
930 }
931
932 if($tmp_mail_options->getIncomingType() == $this->mail_options->BOTH)
933 {
934 $as_email[] = $tmp_user->getEmail();
935 }
936 }
937
938 $mbox->setUserId($id);
939 $inbox_id = $mbox->getInboxFolder();
940
941 $mail_id = $this->sendInternalMail(
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
944 );
945
946 if($a_attachments)
947 {
948 $this->mfile->assignAttachmentsToDirectory($mail_id, $sent_mail_id, $a_attachments);
949 }
950 }
951
952 if(count($as_email))
953 {
954 $this->sendMimeMail('', '', implode(',', $as_email), $a_subject, $cc_and_bcc_message, $a_attachments);
955 }
956 }
957
958 return true;
959 }
960
965 protected function getUserIds($a_recipients)
966 {
967 $usr_ids = array();
968
969 require_once 'Services/Mail/classes/Address/Type/class.ilMailAddressTypeFactory.php';
970 $recipients = $this->parseAddresses($a_recipients);
971 foreach($recipients as $recipient)
972 {
973 $address_type = ilMailAddressTypeFactory::getByPrefix($recipient);
974 $usr_ids = array_merge($usr_ids, $address_type->resolve());
975 }
976
977 return array_unique($usr_ids);
978 }
979
989 protected function checkMail($a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_m_subject, $a_m_message, $a_type)
990 {
991 $errors = array();
992 foreach(array(
993 $a_m_subject => array('mail_add_subject'),
994 $a_rcp_to => array('mail_add_recipient')
995 ) as $string => $e)
996 {
997 if(strlen($string) === 0)
998 {
999 $errors[] = $e;
1000 }
1001 }
1002
1003 return $errors;
1004 }
1005
1013 protected function checkRecipients($a_recipients)
1014 {
1015 $errors = array();
1016
1017 try
1018 {
1019 require_once 'Services/Mail/classes/Address/Type/class.ilMailAddressTypeFactory.php';
1020 $recipients = $this->parseAddresses($a_recipients);
1021 foreach($recipients as $recipient)
1022 {
1023 $address_type = ilMailAddressTypeFactory::getByPrefix($recipient);
1024 if(!$address_type->validate($this->user_id))
1025 {
1026 $errors = array_merge($errors, $address_type->getErrors());
1027 }
1028 }
1029 }
1030 catch(ilException $e)
1031 {
1032 $colon_pos = strpos($e->getMessage(), ':');
1033 throw new ilMailException(($colon_pos === false) ? $e->getMessage() : substr($e->getMessage(), $colon_pos + 2));
1034 }
1035
1036 return $errors;
1037 }
1038
1056 public function savePostData(
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()
1060 )
1061 {
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';
1070
1071 $this->db->replace(
1072 $this->table_mail_saved,
1073 array(
1074 'user_id' => array('integer', $this->user_id)
1075 ),
1076 array(
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))
1088 )
1089 );
1090
1091 $this->getSavedData();
1092
1093 return true;
1094 }
1095
1099 public function getSavedData()
1100 {
1101 $res = $this->db->queryF(
1102 "SELECT * FROM {$this->table_mail_saved} WHERE user_id = %s",
1103 array('integer'),
1104 array($this->user_id)
1105 );
1106
1107 $this->mail_data = $this->fetchMailData($this->db->fetchAssoc($res));
1108
1109 return $this->mail_data;
1110 }
1111
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)
1125 {
1129 global $rbacsystem;
1130
1131 ilLoggerFactory::getLogger('mail')->debug(
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
1137 );
1138
1139 $this->mail_to_global_roles = true;
1140 if($this->user_id != ANONYMOUS_USER_ID)
1141 {
1142 $this->mail_to_global_roles = $rbacsystem->checkAccessOfUser($this->user_id, 'mail_to_global_roles', $this->mail_obj_ref_id);
1143 }
1144
1145 if(in_array('system', $a_type))
1146 {
1147 $a_type = array('system');
1148 }
1149
1150 if($a_attachment && !$this->mfile->checkFilesExist($a_attachment))
1151 {
1152 return array(array('mail_attachment_file_not_exist', $a_attachment));
1153 }
1154
1155 $errors = $this->checkMail($a_rcp_to, $a_rcp_cc, $a_rcp_bc, $a_m_subject, $a_m_message, $a_type);
1156 if(count($errors) > 0)
1157 {
1158 return $errors;
1159 }
1160
1161 $errors = $this->validateRecipients($a_rcp_to, $a_rcp_cc, $a_rcp_bc);
1162 if(count($errors) > 0)
1163 {
1164 return $errors;
1165 }
1166
1167 $rcp_to = $a_rcp_to;
1168 $rcp_cc = $a_rcp_cc;
1169 $rcp_bc = $a_rcp_bc;
1170
1171 $c_emails = $this->getCountRecipients($rcp_to, $rcp_cc, $rcp_bc, true);
1172
1173 if(
1174 $c_emails && $this->user_id != ANONYMOUS_USER_ID &&
1175 !$rbacsystem->checkAccessOfUser($this->user_id, 'smtp_mail', $this->mail_obj_ref_id)
1176 )
1177 {
1178 return array(array('mail_no_permissions_write_smtp'));
1179 }
1180
1181 if($this->appendInstallationSignature())
1182 {
1183 $a_m_message .= self::_getInstallationSignature();
1184 }
1185
1186 $sent_id = $this->saveInSentbox($a_attachment,$a_rcp_to,$a_rcp_cc,$a_rcp_bc,$a_type, $a_m_subject, $a_m_message);
1187
1188 if($a_attachment)
1189 {
1190 $this->mfile->assignAttachmentsToDirectory($sent_id, $sent_id);
1191 $this->mfile->saveFiles($sent_id, $a_attachment);
1192 }
1193
1194 if($c_emails)
1195 {
1196 $externalMailRecipientsTo = $this->getEmailRecipients($rcp_to);
1197 $externalMailRecipientsCc = $this->getEmailRecipients($rcp_cc);
1198 $externalMailRecipientsBcc = $this->getEmailRecipients($rcp_bc);
1199
1200 ilLoggerFactory::getLogger('mail')->debug(
1201 "Parsed external mail addresses from given recipients:" .
1202 " To: " . $externalMailRecipientsTo .
1203 " | CC: " . $externalMailRecipientsCc .
1204 " | BCC: " . $externalMailRecipientsBcc .
1205 " | Subject: " . $a_m_subject
1206 );
1207
1208 $this->sendMimeMail(
1209 $externalMailRecipientsTo,
1210 $externalMailRecipientsCc,
1211 $externalMailRecipientsBcc,
1212 $a_m_subject,
1213 $a_use_placeholders ? $this->replacePlaceholders($a_m_message) : $a_m_message,
1214 $a_attachment,
1215 0
1216 );
1217 }
1218 else
1219 {
1220 ilLoggerFactory::getLogger('mail')->debug("No external mail addresses given in recipient string");
1221 }
1222
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))
1224 {
1225 return array(array('mail_send_error'));
1226 }
1227
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))
1229 {
1230 return array(array('mail_send_error'));
1231 }
1232
1233 if(!$this->getSaveInSentbox())
1234 {
1235 $this->deleteMails(array($sent_id));
1236 }
1237
1238 return array();
1239 }
1240
1247 public function validateRecipients($a_rcp_to, $a_rcp_cc, $a_rcp_bc)
1248 {
1249 try
1250 {
1251 $errors = array();
1252 $errors = array_merge($errors, $this->checkRecipients($a_rcp_to));
1253 $errors = array_merge($errors, $this->checkRecipients($a_rcp_cc));
1254 $errors = array_merge($errors, $this->checkRecipients($a_rcp_bc));
1255
1256 if(count($errors) > 0)
1257 {
1258 return array_merge(array(array('mail_following_rcp_not_valid')), $errors);
1259 }
1260 }
1261 catch(ilMailException $e)
1262 {
1263 return array(array('mail_generic_rcp_error', $e->getMessage()));
1264 }
1265
1266 return array();
1267 }
1268
1280 protected function saveInSentbox($a_attachment, $a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_type, $a_m_subject, $a_m_message)
1281 {
1282 require_once 'Services/Mail/classes/class.ilMailbox.php';
1283
1284 $mbox = new ilMailbox($this->user_id);
1285 $sent_folder_id = $mbox->getSentFolder();
1286
1287 return $this->sendInternalMail(
1288 $sent_folder_id, $this->user_id, $a_attachment,
1289 $a_rcp_to,$a_rcp_cc, $a_rcp_bcc,
1290 'read', $a_type, 0,
1291 $a_m_subject, $a_m_message, $this->user_id, 0
1292 );
1293 }
1294
1299 protected function getMimeMailSender()
1300 {
1302 global $ilUser;
1303
1304 if($this->user_id && $this->user_id != ANONYMOUS_USER_ID)
1305 {
1306 $email = $ilUser->getEmail();
1307 $fullname = $ilUser->getFullname();
1308 if($ilUser->getId() != $this->user_id)
1309 {
1310 $user = self::getCachedUserInstance($this->user_id);
1311 $email = $user->getEmail();
1312 $fullname = $user->getFullname();
1313 }
1314
1315 $sender = array($email, $fullname);
1316 }
1317 else
1318 {
1319 $sender = self::getIliasMailerAddress();
1320 }
1321
1322 return $sender;
1323 }
1324
1329 public static function getIliasMailerAddress()
1330 {
1332 global $ilSetting;
1333
1334 $no_reply_adress = trim($ilSetting->get('mail_external_sender_noreply'));
1335 if(strlen($no_reply_adress))
1336 {
1337 if(strpos($no_reply_adress, '@') === false)
1338 {
1339 $no_reply_adress = 'noreply@' . $no_reply_adress;
1340 }
1341
1342 if(!ilUtil::is_email($no_reply_adress))
1343 {
1344 $no_reply_adress = 'noreply@' . $_SERVER['SERVER_NAME'];
1345 }
1346
1347 $sender = array($no_reply_adress, self::_getIliasMailerName());
1348 }
1349 else
1350 {
1351 $sender = array('noreply@' . $_SERVER['SERVER_NAME'], self::_getIliasMailerName());
1352 }
1353
1354 return $sender;
1355 }
1356
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)
1370 {
1371 require_once 'Services/Mail/classes/class.ilMimeMail.php';
1372
1373 $a_m_subject = self::getSubjectPrefix() . ' ' . $a_m_subject;
1374 $sender = $this->getMimeMailSender();
1375
1376 // #10854
1377 if($this->isSOAPEnabled() && !$a_no_soap)
1378 {
1379 require_once 'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
1380 $soap_client = new ilSoapClient();
1381 $soap_client->setResponseTimeout(5);
1382 $soap_client->enableWSDL(true);
1383 $soap_client->init();
1384
1385 $attachments = array();
1386 $a_attachments = $a_attachments ? $a_attachments : array();
1387 foreach($a_attachments as $attachment)
1388 {
1389 $attachments[] = $this->mfile->getAbsolutePath($attachment);
1390 }
1391
1392 // mjansen: switched separator from "," to "#:#" because of mantis bug #6039
1393 $attachments = implode('#:#', $attachments);
1394 // mjansen: use "#:#" as leading delimiter
1395 if(strlen($attachments))
1396 {
1397 $attachments = "#:#" . $attachments;
1398 }
1399
1400 $soap_client->call('sendMail', array(
1401 session_id() . '::' . $_COOKIE['ilClientId'],
1402 $a_rcp_to,
1403 $a_rcp_cc,
1404 $a_rcp_bcc,
1405 is_array($sender) ? implode('#:#', $sender) : $sender,
1406 $a_m_subject,
1407 $a_m_message,
1408 $attachments
1409 ));
1410
1411 return true;
1412 }
1413 else
1414 {
1415 // send direct
1416 include_once "Services/Mail/classes/class.ilMimeMail.php";
1417
1418 $mmail = new ilMimeMail();
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);
1424
1425 if($a_rcp_cc)
1426 {
1427 $mmail->Cc($a_rcp_cc);
1428 }
1429
1430 if($a_rcp_bcc)
1431 {
1432 $mmail->Bcc($a_rcp_bcc);
1433 }
1434
1435 if(is_array($a_attachments))
1436 {
1437 foreach($a_attachments as $attachment)
1438 {
1439 $mmail->Attach($this->mfile->getAbsolutePath($attachment), '', 'inline', $attachment);
1440 }
1441 }
1442
1443 $mmail->Send();
1444 }
1445 }
1446
1451 public function saveAttachments($a_attachments)
1452 {
1453 $this->db->update($this->table_mail_saved,
1454 array(
1455 'attachments' => array('clob', serialize($a_attachments))
1456 ),
1457 array(
1458 'user_id' => array('integer', $this->user_id)
1459 )
1460 );
1461
1462 return true;
1463 }
1464
1471 protected function parseAddresses($addresses)
1472 {
1473 if(strlen($addresses) > 0)
1474 {
1475 ilLoggerFactory::getLogger('mail')->debug(sprintf(
1476 "Started parsing of recipient string: %s", $addresses
1477 ));
1478 }
1479
1480 require_once 'Services/Mail/classes/Address/Parser/class.ilMailRfc822AddressParserFactory.php';
1482 $parsedAddresses = $parser->parse();
1483
1484 if(strlen($addresses) > 0)
1485 {
1486 ilLoggerFactory::getLogger('mail')->debug(sprintf(
1487 "Parsed addresses: %s", implode(',', array_map(function(ilMailAddress $address) {
1488 return $address->getMailbox() . '@' . $address->getHost();
1489 }, $parsedAddresses))
1490 ));
1491 }
1492
1493 return $parsedAddresses;
1494 }
1495
1501 protected function getCountRecipient($a_recipients, $a_only_email = true)
1502 {
1503 $counter = 0;
1504
1505 $recipients = $this->parseAddresses($a_recipients);
1506 foreach($recipients as $recipient)
1507 {
1508 if($a_only_email)
1509 {
1510 // Fixed mantis bug #5875
1511 if(ilObjUser::_lookupId($recipient->getMailbox() . '@' . $recipient->getHost()))
1512 {
1513 continue;
1514 }
1515
1516 // Addresses which aren't on the self::ILIAS_HOST host, and
1517 // which have a mailbox which does not start with '#',
1518 // are external e-mail addresses
1519 if($recipient->getHost() != self::ILIAS_HOST && substr($recipient->getMailbox(), 0, 1) != '#')
1520 {
1521 ++$counter;
1522 }
1523 }
1524 else
1525 {
1526 ++$counter;
1527 }
1528 }
1529
1530 return $counter;
1531 }
1532
1540 protected function getCountRecipients($a_to, $a_cc, $a_bcc, $a_only_email = true)
1541 {
1542 return
1543 $this->getCountRecipient($a_to, $a_only_email) +
1544 $this->getCountRecipient($a_cc, $a_only_email) +
1545 $this->getCountRecipient($a_bcc, $a_only_email);
1546 }
1547
1552 protected function getEmailRecipients($a_recipients)
1553 {
1554 $rcp = array();
1555
1556 $recipients = $this->parseAddresses($a_recipients);
1557 foreach($recipients as $recipient)
1558 {
1559 if(substr($recipient->getMailbox(), 0, 1) != '#' && $recipient->getHost() != self::ILIAS_HOST)
1560 {
1561 // Fixed mantis bug #5875
1562 if(ilObjUser::_lookupId($recipient->getMailbox() . '@' . $recipient->getHost()))
1563 {
1564 continue;
1565 }
1566
1567 $rcp[] = $recipient->getMailbox() . '@' . $recipient->getHost();
1568 }
1569 }
1570
1571 return implode(',', $rcp);
1572 }
1573
1579 public static function _getAutoGeneratedMessageString(ilLanguage $lang = null)
1580 {
1584 global $ilSetting;
1585
1586 if(!($lang instanceof ilLanguage))
1587 {
1588 require_once 'Services/Language/classes/class.ilLanguageFactory.php';
1590 }
1591
1592 $lang->loadLanguageModule('mail');
1593
1594 return sprintf(
1595 $lang->txt('mail_auto_generated_info'),
1596 $ilSetting->get('inst_name','ILIAS 5'),
1598 ). "\n\n";
1599 }
1600
1605 public static function _getIliasMailerName()
1606 {
1610 global $ilSetting;
1611
1612 if(strlen($ilSetting->get('mail_system_sender_name')))
1613 {
1614 return $ilSetting->get('mail_system_sender_name');
1615 }
1616 else if(strlen($ilSetting->get('short_inst_name')))
1617 {
1618 return $ilSetting->get('short_inst_name');
1619 }
1620
1621 return 'ILIAS';
1622 }
1623
1629 public function appendInstallationSignature($a_flag = null)
1630 {
1631 if(null === $a_flag)
1632 {
1634 }
1635
1636 $this->appendInstallationSignature = $a_flag;
1637 return $this;
1638 }
1639
1643 public static function _getInstallationSignature()
1644 {
1646 global $ilClientIniFile;
1647
1648 $signature = "\n\n* * * * *\n";
1649
1650 $signature .= $ilClientIniFile->readVariable('client', 'name') . "\n";
1651 if(strlen($desc = $ilClientIniFile->readVariable('client', 'description')))
1652 {
1653 $signature .= $desc . "\n";
1654 }
1655
1656 $signature .= ilUtil::_getHttpPath();
1657
1658 $clientdirs = glob(ILIAS_WEB_DIR . '/*', GLOB_ONLYDIR);
1659 if(is_array($clientdirs) && count($clientdirs) > 1)
1660 {
1661 $signature .= '/login.php?client_id=' . CLIENT_ID; // #18051
1662 }
1663
1664 $signature .= "\n\n";
1665
1666 return $signature;
1667 }
1668
1673 public static function getSubjectPrefix()
1674 {
1676 global $ilSetting;
1677
1678 return $ilSetting->get('mail_subject_prefix', '');
1679 }
1680
1686 public static function getSalutation($a_usr_id, ilLanguage $a_language = null)
1687 {
1689 global $lng;
1690
1691 $lang = ($a_language instanceof ilLanguage) ? $a_language : $lng;
1692 $lang->loadLanguageModule('mail');
1693
1694 $gender = ilObjUser::_lookupGender($a_usr_id);
1695 $gender = $gender ? $gender : 'n';
1696 $name = ilObjUser::_lookupName($a_usr_id);
1697
1698 if(!strlen($name['firstname']))
1699 {
1700 return $lang->txt('mail_salutation_anonymous') . ',';
1701 }
1702
1703 return
1704 $lang->txt('mail_salutation_' . $gender) . ' ' .
1705 ($name['title'] ? $name['title'] . ' ' : '') .
1706 ($name['firstname'] ? $name['firstname'] . ' ' : '') .
1707 $name['lastname'] . ',';
1708 }
1709
1714 protected static function getCachedUserInstance($a_usr_id)
1715 {
1716 if(isset(self::$userInstances[$a_usr_id]))
1717 {
1718 return self::$userInstances[$a_usr_id];
1719 }
1720
1721 self::$userInstances[$a_usr_id] = new ilObjUser($a_usr_id);
1722 return self::$userInstances[$a_usr_id];
1723 }
1724}
sprintf('%.4f', $callTime)
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
$parser
Definition: BPMN2Parser.php:24
$_COOKIE['ilClientId']
Definition: BPMN2Parser.php:15
if(php_sapi_name() !='cli') $in
Definition: Utf8Test.php:37
An exception for terminatinating execution or to throw for unit testing.
const CONTEXT_CRON
static getType()
Get context type.
Base class for ILIAS Exception handling.
This class handles all operations on files (attachments) in directory ilias_data/mail.
static _getLanguage($a_lang_key='')
Get langauge object.
language handling
static getLogger($a_component_id)
Get component logger.
static getByPrefix(ilMailAddress $a_address)
Class ilMailAddress.
Class ilMailException.
static getMailObjectRefId()
Determines the reference id of the mail object and stores this information in a local cache variable.
Class UserMail this class handles user mails.
This class handles base functions for mail handling.
static getCachedUserInstance($a_usr_id)
markUnread(array $a_mail_ids)
$table_mail_saved
getCountRecipient($a_recipients, $a_only_email=true)
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)
getEmailRecipients($a_recipients)
appendInstallationSignature($a_flag=null)
Setter/Getter for appending the installation signarue.
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.
setSaveInSentbox($a_save_in_sentbox)
getCountRecipients($a_to, $a_cc, $a_bcc, $a_only_email=true)
getMail($a_mail_id)
checkRecipients($a_recipients)
Check if recipients are valid.
markRead(array $a_mail_ids)
enableSOAP($a_status)
Define if external mails should be sent using SOAP client or not.
static $userInstances
getNextMail($a_mail_id)
replacePlaceholders($a_message, $a_user_id=0, $replace_empty=true)
moveMailsToFolder(array $a_mail_ids, $a_folder_id)
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())
$save_in_sentbox
$mail_obj_ref_id
countMailsOfFolder($a_folder_id)
getUserIds($a_recipients)
existsRecipient($a_recipient, $a_existing_recipients)
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 @access private
getMailsOfFolder($a_folder_id, $filter=array())
saveAttachments($a_attachments)
getNewDraftId($usrId, $folderId)
fetchMailData($a_row)
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.
getPreviousMail($a_mail_id)
$mail_to_global_roles
deleteMailsOfFolder($a_folder_id)
$appendInstallationSignature
checkMail($a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_m_subject, $a_m_message, $a_type)
parseAddresses($addresses)
Explode recipient string, allowed separators are ',' ';' ' ' Returns an array with recipient ilMailAd...
getMailObjectReferenceId()
validateRecipients($a_rcp_to, $a_rcp_cc, $a_rcp_bc)
readMailObjectReferenceId()
Read and set the mail object ref id (administration node)
getSaveInSentbox()
const ILIAS_HOST
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 @access public
Mail Box class Base class for creating and handling mail boxes.
this class encapsulates the PHP mail() function.
static _lookupPref($a_usr_id, $a_keyword)
static _lookupId($a_user_str)
Lookup id by login.
static _lookupGender($a_user_id)
Lookup gender.
static _lookupName($a_user_id)
lookup user name
static is_email($a_email)
This preg-based function checks whether an e-mail address is formally valid.
static _getHttpPath()
$counter
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\s+" &#(? foreach( $entity_files as $file) $output
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
Definition: langwiz.php:349
global $ilSetting
Definition: privfeed.php:17
global $ilDB
$errors
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
$ilUser
Definition: imgupload.php:18
$a_type
Definition: workflow.php:93