128 require_once
"Services/User/classes/class.ilObjUser.php";
242 require_once
"classes/class.ilFileDataMail.php";
243 require_once
"Services/Mail/classes/class.ilMailOptions.php";
244 require_once
"Services/Contact/classes/class.ilMailingLists.php";
248 $lng->loadLanguageModule(
"mail");
253 $this->table_mail =
'mail';
254 $this->table_mail_saved =
'mail_saved';
255 $this->user_id = $a_user_id;
258 if(is_object($ilUser))
273 if(self::_usePearMail())
276 if(is_a($recipients,
'PEAR_Error'))
282 foreach($recipients as $rcp)
284 if (substr($rcp->mailbox, 0, 1) !=
'#')
286 if(trim($rcp->mailbox) == trim($a_recipient) ||
287 trim($rcp->mailbox.
'@'.$rcp->host) == trim($a_recipient))
292 else if (substr($rcp->mailbox, 0, 7) ==
'#il_ml_')
294 if(trim($rcp->mailbox.
'@'.$rcp->host) == trim($a_recipient))
301 if(trim($rcp->mailbox.
'@'.$rcp->host) == trim($a_recipient))
312 if(count($recipients))
314 foreach($recipients as $recipient)
316 if(trim($recipient) == trim($a_recipient))
336 $this->soap_enabled = $a_status;
342 if(!extension_loaded(
'curl') || !$ilSetting->get(
'soap_user_administration'))
353 $this->save_in_sentbox = $a_save_in_sentbox;
368 $this->mail_send_type = $a_types;
378 $this->mail_rcp_to = $a_rcp_to;
388 $this->mail_rcp_cc = $a_rcp_cc;
398 $this->mail_rcp_bc = $a_rcp_bc;
408 $this->mail_subject = $a_subject;
418 $this->mail_message = $a_message;
430 if (!MAIL_SETTINGS_ID)
432 $res = $ilDB->queryf(
'
433 SELECT object_reference.ref_id FROM object_reference, tree, object_data
434 WHERE tree.parent = %s
435 AND object_data.type = %s
436 AND object_reference.ref_id = tree.child
437 AND object_reference.obj_id = object_data.obj_id',
438 array(
'integer',
'text'),
439 array(SYSTEM_FOLDER_ID,
'mail'));
443 $this->mail_obj_ref_id =
$row[
"ref_id"];
448 $this->mail_obj_ref_id = MAIL_SETTINGS_ID;
469 $users = trim($users);
472 if(strstr($users,
','))
474 $rcp_to_array = array();
476 $recipients = explode(
',', $users);
477 foreach($recipients as $recipient)
479 $recipient = trim($recipient);
486 $rcp_to_array[] = $tmp_obj->getFullname().
' ['.$recipient.
']';
490 $rcp_to_array[] = $recipient;
496 $rcp_to_array[] = $recipient;
500 return trim(implode(
', ', $rcp_to_array));
509 return $tmp_obj->getFullname().
' ['.$users.
']';
525 return $this->lng->txt(
'not_available');
534 $res = $ilDB->queryf(
"
535 SELECT b.* FROM " . $this->table_mail .
" a
536 INNER JOIN ".$this->table_mail .
" b ON b.folder_id = a.folder_id
537 AND b.user_id = a.user_id AND b.send_time > a.send_time
539 AND a.mail_id = %s ORDER BY b.send_time ASC",
540 array(
'integer',
'integer'),
541 array($this->user_id, $a_mail_id));
553 $res = $ilDB->queryf(
"
554 SELECT b.* FROM " . $this->table_mail .
" a
555 INNER JOIN ".$this->table_mail .
" b ON b.folder_id = a.folder_id
556 AND b.user_id = a.user_id AND b.send_time < a.send_time
558 AND a.mail_id = %s ORDER BY b.send_time DESC",
559 array(
'integer',
'integer'),
560 array($this->user_id, $a_mail_id));
578 $this->mail_counter = array();
579 $this->mail_counter[
'read'] = 0;
580 $this->mail_counter[
'unread'] = 0;
582 $query =
"SELECT sender_id, m_subject, mail_id, m_status, send_time FROM ". $this->table_mail .
"
583 LEFT JOIN object_data ON obj_id = sender_id
586 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)) ";
588 if($filter[
'status'])
590 $query .=
' AND m_status = '.$ilDB->quote($filter[
'status'],
'text');
594 $query .=
' AND '.$ilDB->like(
'm_type',
'text',
'%%:"'.$filter[
'type'].
'"%%',
false);
597 $query .=
" ORDER BY send_time DESC";
600 array(
'integer',
'integer'),
601 array($this->user_id, $a_folder_id));
603 while (
$row = $ilDB->fetchObject(
$res))
607 if($tmp[
'm_status'] ==
'read')
609 ++$this->mail_counter[
'read'];
612 if($tmp[
'm_status'] ==
'unread')
614 ++$this->mail_counter[
'unread'];
620 $this->mail_counter[
'total'] = count($output);
622 return $output ? $output : array();
635 $res = $ilDB->queryf(
"
636 SELECT COUNT(*) FROM ". $this->table_mail .
"
639 array(
'integer',
'integer'),
640 array($this->user_id, $a_folder_id));
642 return $res->numRows();
683 return is_array($this->mail_counter) ? $this->mail_counter : array(
699 $res = $ilDB->queryf(
"
700 SELECT * FROM ". $this->table_mail .
"
703 array(
'integer',
'integer'),
704 array($this->user_id, $a_mail_id));
723 $data_types = array();
725 $query =
"UPDATE ". $this->table_mail .
"
727 WHERE user_id = %s ";
728 array_push($data_types,
'text',
'integer');
729 array_push(
$data,
'read', $this->user_id);
731 $cnt_mail_ids = count($a_mail_ids);
733 if (is_array($a_mail_ids) &&
734 count($a_mail_ids) > 0)
737 $in =
'mail_id IN (';
739 foreach($a_mail_ids as $a_mail_id)
741 array_push(
$data, $a_mail_id);
742 array_push($data_types,
'integer');
744 if($counter > 0)
$in .=
',';
769 $data_types = array();
771 $query =
"UPDATE ". $this->table_mail .
"
773 WHERE user_id = %s ";
774 array_push($data_types,
'text',
'integer');
775 array_push(
$data,
'unread', $this->user_id);
777 $cnt_mail_ids = count($a_mail_ids);
779 if (is_array($a_mail_ids) &&
780 count($a_mail_ids) > 0)
783 $in =
'mail_id IN (';
785 foreach($a_mail_ids as $a_mail_id)
787 array_push(
$data, $a_mail_id);
788 array_push($data_types,
'integer');
790 if($counter > 0)
$in .=
',';
799 $statement = $ilDB->manipulateF(
$query, $data_types,
$data);
816 $data_types = array();
818 $query =
"UPDATE ". $this->table_mail .
"
820 WHERE user_id = %s ";
821 array_push($data_types,
'text',
'integer');
822 array_push(
$data, $a_folder_id, $this->user_id);
824 $cnt_mail_ids = count($a_mail_ids);
826 if (is_array($a_mail_ids) &&
827 count($a_mail_ids) > 0)
830 $in =
'mail_id IN (';
832 foreach($a_mail_ids as $a_mail_id)
834 array_push(
$data, $a_mail_id);
835 array_push($data_types,
'integer');
837 if($counter > 0)
$in .=
',';
846 $statement = $ilDB->manipulateF(
$query, $data_types,
$data);
861 foreach ($a_mail_ids as $id)
863 $statement = $ilDB->manipulateF(
"
864 DELETE FROM ". $this->table_mail .
"
867 array(
'integer',
'integer'),
868 array($this->user_id, $id));
870 $this->mfile->deassignAttachmentFromDirectory($id);
887 "mail_id" => $a_row->mail_id,
888 "user_id" => $a_row->user_id,
889 "folder_id" => $a_row->folder_id,
890 "sender_id" => $a_row->sender_id,
891 "attachments" => unserialize(stripslashes($a_row->attachments)),
892 "send_time" => $a_row->send_time,
893 "rcp_to" => $a_row->rcp_to,
894 "rcp_cc" => $a_row->rcp_cc,
895 "rcp_bcc" => $a_row->rcp_bcc,
896 "m_status" => $a_row->m_status,
897 "m_type" => unserialize(stripslashes($a_row->m_type)),
898 "m_email" => $a_row->m_email,
899 "m_subject" => $a_row->m_subject,
900 "m_message" => $a_row->m_message,
901 "import_name" => $a_row->import_name,
902 "use_placeholders"=> $a_row->use_placeholders);
914 $a_draft_id = 0, $a_use_placeholders = 0)
918 $ilDB->update($this->table_mail,
920 'folder_id' => array(
'integer', $a_folder_id),
921 'attachments' => array(
'clob', serialize($a_attachments)),
922 'send_time' => array(
'timestamp', date(
'Y-m-d H:i:s', time())),
923 'rcp_to' => array(
'clob', $a_rcp_to),
924 'rcp_cc' => array(
'clob', $a_rcp_cc),
925 'rcp_bcc' => array(
'clob', $a_rcp_bcc),
926 'm_status' => array(
'text',
'read'),
927 'm_type' => array(
'text', serialize($a_m_type)),
928 'm_email' => array(
'integer', $a_m_email),
929 'm_subject' => array(
'text', $a_m_subject),
930 'm_message' => array(
'clob', $a_m_message),
931 'use_placeholders' => array(
'integer', $a_use_placeholders)
934 'mail_id' => array(
'integer', $a_draft_id)
969 $a_user_id = 0, $a_use_placeholders = 0)
976 if ($a_use_placeholders)
982 $a_use_placeholders =
'0';
986 if(!$a_user_id) $a_user_id =
'0';
987 if(!$a_folder_id) $a_folder_id =
'0';
988 if(!$a_sender_id) $a_sender_id = NULL;
989 if(!$a_attachments) $a_attachments = NULL;
990 if(!$a_rcp_to) $a_rcp_to = NULL;
991 if(!$a_rcp_cc) $a_rcp_cc = NULL;
992 if(!$a_rcp_bcc) $a_rcp_bcc = NULL;
993 if(!$a_status) $a_status = NULL;
994 if(!$a_m_type) $a_m_type = NULL;
995 if(!$a_m_email) $a_m_email = NULL;
996 if(!$a_m_subject) $a_m_subject = NULL;
997 if(!$a_m_message) $a_m_message = NULL;
1000 $next_id = $ilDB->nextId($this->table_mail);
1002 $ilDB->insert($this->table_mail, array(
1003 'mail_id' => array(
'integer', $next_id),
1004 'user_id' => array(
'integer', $a_user_id),
1005 'folder_id' => array(
'integer', $a_folder_id),
1006 'sender_id' => array(
'integer', $a_sender_id),
1007 'attachments' => array(
'clob', serialize($a_attachments)),
1008 'send_time' => array(
'timestamp', date(
'Y-m-d H:i:s', time())),
1009 'rcp_to' => array(
'clob', $a_rcp_to),
1010 'rcp_cc' => array(
'clob', $a_rcp_cc),
1011 'rcp_bcc' => array(
'clob', $a_rcp_bcc),
1012 'm_status' => array(
'text', $a_status),
1013 'm_type' => array(
'text', serialize($a_m_type)),
1014 'm_email' => array(
'integer', $a_m_email),
1015 'm_subject' => array(
'text', $a_m_subject),
1016 'm_message' => array(
'clob', $a_m_message)
1030 switch (
$user->getGender())
1032 case 'f': $gender_salut = $lng->txt(
'salutation_f');
1034 case 'm': $gender_salut = $lng->txt(
'salutation_m');
1038 $a_message = str_replace(
'[MAIL_SALUTATION]', $gender_salut, $a_message);
1039 $a_message = str_replace(
'[LOGIN]',
$user->getLogin(), $a_message);
1040 $a_message = str_replace(
'[FIRST_NAME]',
$user->getFirstname(), $a_message);
1041 $a_message = str_replace(
'[LAST_NAME]',
$user->getLastname(), $a_message);
1042 $a_message = str_replace(
'[ILIAS_URL]', ILIAS_HTTP_PATH.
'/login.php?client_id='.CLIENT_ID, $a_message);
1043 $a_message = str_replace(
'[CLIENT_NAME]', CLIENT_NAME, $a_message);
1063 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)
1067 include_once
'Services/Mail/classes/class.ilMailbox.php';
1068 include_once
'./Services/User/classes/class.ilObjUser.php';
1080 if (!$a_use_placeholders) # No Placeholders
1082 $rcp_ids = $this->
getUserIds(trim($a_rcp_to).
','.trim($a_rcp_cc).
','.trim($a_rcp_bcc));
1084 $as_email = array();
1086 foreach($rcp_ids as $id)
1093 $user_is_active = $tmp_user->getActive();
1094 $user_can_read_internal_mails = $tmp_user->hasAcceptedUserAgreement() &&
1095 $tmp_user->checkTimeLimit();
1098 if (in_array(
'system', $a_type) && !$user_can_read_internal_mails)
1109 if (!$user_can_read_internal_mails ||
1110 $tmp_mail_options->getIncomingType() == $this->mail_options->EMAIL)
1116 if ($tmp_mail_options->getIncomingType() == $this->mail_options->BOTH)
1121 $mbox->setUserId($id);
1122 $inbox_id = $mbox->getInboxFolder();
1125 $a_attachments, $a_rcp_to,
1126 $a_rcp_cc,
'',
'unread', $a_type,
1127 0, $a_subject, $a_message, $id, 0);
1130 $this->mfile->assignAttachmentsToDirectory($mail_id, $sent_mail_id, $a_attachments);
1138 if (count($as_email) == 1)
1144 foreach ($as_email as $id)
1150 if(count($to) > 0 || count($bcc) > 0)
1152 $this->
sendMimeMail(implode(
',', $to),
'', implode(
',', $bcc), $a_subject, $a_message, $a_attachments);
1155 else # Use Placeholders
1158 $rcp_ids_replace = $this->
getUserIds(trim($a_rcp_to));
1161 $rcp_ids_no_replace = $this->
getUserIds(trim($a_rcp_cc).
','.trim($a_rcp_bcc));
1163 $as_email = array();
1166 foreach($rcp_ids_replace as $id)
1173 $user_is_active = $tmp_user->getActive();
1174 $user_can_read_internal_mails = $tmp_user->hasAcceptedUserAgreement() &&
1175 $tmp_user->checkTimeLimit();
1178 if (in_array(
'system', $a_type) && !$user_can_read_internal_mails)
1189 if (!$user_can_read_internal_mails ||
1190 $tmp_mail_options->getIncomingType() == $this->mail_options->EMAIL)
1196 if ($tmp_mail_options->getIncomingType() == $this->mail_options->BOTH)
1201 $mbox->setUserId($id);
1202 $inbox_id = $mbox->getInboxFolder();
1205 $a_attachments, $a_rcp_to,
1206 $a_rcp_cc,
'',
'unread', $a_type,
1207 0, $a_subject, $a_message, $id, 1);
1210 $this->mfile->assignAttachmentsToDirectory($mail_id, $sent_mail_id, $a_attachments);
1214 if (count($as_email))
1216 foreach ($as_email as $id)
1222 $as_email = array();
1225 foreach($rcp_ids_no_replace as $id)
1232 $user_is_active = $tmp_user->getActive();
1233 $user_can_read_internal_mails = $tmp_user->hasAcceptedUserAgreement()
1234 && $tmp_user->checkTimeLimit();
1240 if (in_array(
'system', $a_type) && !$user_can_read_internal_mails)
1247 if (!$user_can_read_internal_mails ||
1248 $tmp_mail_options->getIncomingType() == $this->mail_options->EMAIL)
1254 if ($tmp_mail_options->getIncomingType() == $this->mail_options->BOTH)
1259 $mbox->setUserId($id);
1260 $inbox_id = $mbox->getInboxFolder();
1263 $a_attachments, $a_rcp_to,
1264 $a_rcp_cc,
'',
'unread', $a_type,
1265 0, $a_subject, $a_message, $id, 0);
1268 $this->mfile->assignAttachmentsToDirectory($mail_id, $sent_mail_id, $a_attachments);
1272 if (count($as_email))
1274 foreach ($as_email as $id)
1291 global
$log, $rbacreview;
1298 if (! is_a($tmp_names,
'PEAR_Error'))
1300 for ($i = 0;$i < count($tmp_names); $i++)
1302 if ( substr($tmp_names[$i]->mailbox,0,1) ===
'#' ||
1303 (substr($tmp_names[$i]->mailbox,0,1) ===
'"' &&
1304 substr($tmp_names[$i]->mailbox,1,1) ===
'#' ) )
1306 $role_ids = $rbacreview->searchRolesByMailboxAddressList($tmp_names[$i]->mailbox.
'@'.$tmp_names[$i]->host);
1307 foreach($role_ids as $role_id)
1309 foreach($rbacreview->assignedUsers($role_id) as
$usr_id)
1315 else if (strtolower($tmp_names[$i]->host) ==
'ilias')
1349 for ($i = 0;$i < count($tmp_names); $i++)
1351 if (substr($tmp_names[$i],0,1) ==
'#')
1355 include_once(
"./classes/class.ilObjectFactory.php");
1356 include_once(
'./Modules/Group/classes/class.ilObjGroup.php');
1364 foreach ($grp_object->getGroupMemberIds() as $id)
1370 elseif($role_id = $rbacreview->roleExists(addslashes(substr($tmp_names[$i],1))))
1372 foreach($rbacreview->assignedUsers($role_id) as
$usr_id)
1379 else if (!empty($tmp_names[$i]))
1388 return array_unique($ids);
1401 function checkMail($a_rcp_to,$a_rcp_cc,$a_rcp_bcc,$a_m_subject,$a_m_message,$a_type)
1403 $error_message =
'';
1405 $a_m_subject = trim($a_m_subject);
1406 $a_rcp_to = trim($a_rcp_to);
1408 if (empty($a_m_subject))
1410 $error_message .= $error_message ?
"<br>" :
'';
1411 $error_message .= $this->lng->txt(
"mail_add_subject");
1414 if (empty($a_rcp_to))
1416 $error_message .= $error_message ?
"<br>" :
'';
1417 $error_message .= $this->lng->txt(
"mail_add_recipient");
1420 return $error_message;
1431 $addresses = array();
1437 if (! is_a($tmp_rcp,
'PEAR_Error'))
1439 foreach ($tmp_rcp as $rcp)
1442 if (substr($rcp->mailbox,0,1) !=
'#')
1444 if (strtolower($rcp->host) !=
'ilias')
1446 $addresses[] = $rcp->mailbox.
'@'.$rcp->host;
1453 $addresses[] = $tmp_user->getEmail();
1460 $role_ids = $rbacreview->searchRolesByMailboxAddressList($rcp->mailbox.
'@'.$rcp->host);
1461 foreach($role_ids as $role_id)
1463 foreach($rbacreview->assignedUsers($role_id) as
$usr_id)
1466 $addresses[] = $tmp_user->getEmail();
1477 foreach ($tmp_rcp as $rcp)
1480 if (substr($rcp,0,1) !=
'#')
1482 if (strpos($rcp,
'@'))
1484 $addresses[] = $rcp;
1491 $addresses[] = $tmp_user->getEmail();
1498 include_once(
"./classes/class.ilObjectFactory.php");
1499 include_once(
'./Modules/Group/classes/class.ilObjGroup.php');
1508 foreach ($grp_object->getGroupMemberIds() as $id)
1511 $addresses[] = $tmp_user->getEmail();
1529 global $rbacsystem,$rbacreview;
1537 if (is_a($tmp_rcp,
'PEAR_Error'))
1539 $colon_pos = strpos($tmp_rcp->message,
':');
1540 $wrong_rcps =
'<br />'.(($colon_pos ===
false) ? $tmp_rcp->message : substr($tmp_rcp->message, $colon_pos+2));
1544 foreach ($tmp_rcp as $rcp)
1547 if (substr($rcp->mailbox,0,1) !=
'#')
1551 if (
$user_id ==
false && $rcp->host ==
'ilias')
1553 $wrong_rcps .=
"<br />".htmlentities($rcp->mailbox);
1560 if(!$rbacsystem->checkAccessOfUser(
$user_id,
"mail_visible", $this->getMailObjectReferenceId()))
1562 $wrong_rcps .=
"<br />".htmlentities($rcp->mailbox).
1563 " (".$this->lng->txt(
"user_cant_receive_mail").
")";
1568 else if (substr($rcp->mailbox, 0, 7) ==
'#il_ml_')
1570 if (!$this->mlists->mailingListExists($rcp->mailbox))
1572 $wrong_rcps .=
"<br />".htmlentities($rcp->mailbox).
1573 " (".$this->lng->txt(
"mail_no_valid_mailing_list").
")";
1581 $role_ids = $rbacreview->searchRolesByMailboxAddressList($rcp->mailbox.
'@'.$rcp->host);
1583 if(!$this->mail_to_global_roles && is_array($role_ids))
1585 foreach($role_ids as $role_id)
1587 if($rbacreview->isGlobalRole($role_id))
1589 include_once(
'Services/Mail/exceptions/class.ilMailException.php');
1595 if (count($role_ids) == 0)
1597 $wrong_rcps .=
'<br />'.htmlentities($rcp->mailbox).
1598 ' ('.$this->lng->txt(
'mail_no_recipient_found').
')';
1601 else if (count($role_ids) > 1)
1603 $wrong_rcps .=
'<br/>'.htmlentities($rcp->mailbox).
1604 ' ('.sprintf($this->lng->txt(
'mail_multiple_recipients_found'), implode(
',', $role_ids)).
')';
1614 foreach ($tmp_rcp as $rcp)
1621 if (substr($rcp,0,1) !=
'#')
1627 $wrong_rcps .=
"<br />".htmlentities($rcp);
1634 if(!$rbacsystem->checkAccessOfUser(
$user_id,
"mail_visible", $this->getMailObjectReferenceId()))
1636 $wrong_rcps .=
"<br />".htmlentities($rcp).
1637 " (".$this->lng->txt(
"user_cant_receive_mail").
")";
1642 else if (substr($rcp, 0, 7) ==
'#il_ml_')
1644 if (!$this->mlists->mailingListExists($rcp))
1646 $wrong_rcps .=
"<br />".htmlentities($rcp).
1647 " (".$this->lng->txt(
"mail_no_valid_mailing_list").
")";
1656 else if (!$rbacreview->roleExists(addslashes(substr($rcp,1))))
1658 $wrong_rcps .=
"<br />".htmlentities($rcp).
1659 " (".$this->lng->txt(
"mail_no_valid_group_role").
")";
1662 else if (!$this->mail_to_global_roles)
1664 $role_id = $rbacreview->roleExists(addslashes(substr($rcp,1)));
1665 if((
int)$role_id && $rbacreview->isGlobalRole($role_id))
1667 include_once(
'Services/Mail/exceptions/class.ilMailException.php');
1700 $a_use_placeholders)
1705 if(!$a_attachments) $a_attachments = NULL;
1706 if(!$a_rcp_to) $a_rcp_to = NULL;
1707 if(!$a_rcp_cc) $a_rcp_cc = NULL;
1708 if(!$a_rcp_bcc) $a_rcp_bcc = NULL;
1709 if(!$a_m_type) $a_m_type = NULL;
1710 if(!$a_m_email) $a_m_email = NULL;
1711 if(!$a_m_message) $a_m_message = NULL;
1712 if(!$a_use_placeholders) $a_use_placeholders =
'0';
1715 $statement = $ilDB->manipulateF(
'
1716 DELETE FROM '. $this->table_mail_saved .
'
1717 WHERE user_id = %s',
1718 array(
'integer'), array($this->user_id));
1720 $ilDB->insert($this->table_mail_saved, array(
1721 'user_id' => array(
'integer', $a_user_id),
1722 'attachments' => array(
'clob', serialize($a_attachments)),
1723 'rcp_to' => array(
'clob', $a_rcp_to),
1724 'rcp_cc' => array(
'clob', $a_rcp_cc),
1725 'rcp_bcc' => array(
'clob', $a_rcp_bcc),
1726 'm_type' => array(
'text', serialize($a_m_type)),
1727 'm_email' => array(
'integer', $a_m_email),
1728 'm_subject' => array(
'text', $a_m_subject),
1729 'm_message' => array(
'clob', $a_m_message),
1730 'use_placeholders' => array(
'integer', $a_use_placeholders),
1747 $res = $ilDB->queryf(
'
1748 SELECT * FROM '. $this->table_mail_saved .
'
1749 WHERE user_id = %s',
1751 array($this->user_id));
1771 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)
1776 $this->mail_to_global_roles =
true;
1777 if($this->user_id != ANONYMOUS_USER_ID)
1779 $this->mail_to_global_roles = $rbacsystem->checkAccessOfUser($this->user_id,
'mail_to_global_roles', $this->mail_obj_ref_id);
1782 $error_message =
'';
1785 if (in_array(
"system",$a_type))
1788 $a_type = array(
'system');
1793 if (!$this->mfile->checkFilesExist($a_attachment))
1795 return "YOUR LIST OF ATTACHMENTS IS NOT VALID, PLEASE EDIT THE LIST";
1799 if ($error_message = $this->
checkMail($a_rcp_to,$a_rcp_cc,$a_rcp_bc,$a_m_subject,$a_m_message,$a_type))
1801 return $error_message;
1809 $message .= $error_message;
1814 $message .= $error_message;
1819 $message .= $error_message;
1825 return $this->lng->txt($e->getMessage());
1829 if (!empty($message))
1831 return $this->lng->txt(
"mail_following_rcp_not_valid").$message;
1835 if (in_array(
'system',$a_type))
1837 if (!empty($a_attachment))
1839 return $lng->txt(
"mail_no_attach_allowed");
1873 if($c_emails && $this->user_id != ANONYMOUS_USER_ID &&
1874 !$rbacsystem->checkAccessOfUser($this->user_id,
'smtp_mail', $this->mail_obj_ref_id))
1876 return $this->lng->txt(
'mail_no_permissions_write_smtp');
1885 $sent_id = $this->
saveInSentbox($a_attachment,$a_rcp_to,$a_rcp_cc,$a_rcp_bc,$a_type,
1886 $a_m_subject,$a_m_message);
1890 $this->mfile->assignAttachmentsToDirectory($sent_id,$sent_id);
1892 if ($error = $this->mfile->saveFiles($sent_id,$a_attachment))
1911 if (in_array(
'system',$a_type))
1913 if (!$this->
distributeMail($rcp_to,$rcp_cc,$rcp_bc,$a_m_subject,$a_m_message,$a_attachment,$sent_id,$a_type,
'system', $a_use_placeholders))
1915 return $lng->txt(
"mail_send_error");
1919 if (in_array(
'normal',$a_type))
1922 if (!$this->
distributeMail($rcp_to,$rcp_cc,$rcp_bc,$a_m_subject,$a_m_message,$a_attachment,$sent_id,$a_type,
'normal', $a_use_placeholders))
1924 return $lng->txt(
"mail_send_error");
1939 if ($rcpt ==
'')
return $rcpt;
1942 if (!is_array($arrRcpt) || empty($arrRcpt))
return $rcpt;
1944 $new_rcpt = array();
1946 foreach ($arrRcpt as $item)
1950 if (substr($item->mailbox, 0, 7) ==
'#il_ml_')
1952 if ($this->mlists->mailingListExists($item->mailbox))
1954 foreach ($this->mlists->getCurrentMailingList()->getAssignedEntries() as $entry)
1956 $new_rcpt[] = ($entry[
'login'] !=
'' ? $entry[
'login'] : $entry[
'email']);
1962 $new_rcpt[] = $item->mailbox.
'@'.$item->host;
1967 if (substr($item, 0, 7) ==
'#il_ml_')
1969 if ($this->mlists->mailingListExists($item))
1971 foreach ($this->mlists->getCurrentMailingList()->getAssignedEntries() as $entry)
1973 $new_rcpt[] = ($entry[
'login'] !=
'' ? $entry[
'login'] : $entry[
'email']);
1979 $new_rcpt[] = $item;
1984 return implode(
',', $new_rcpt);
2000 $a_m_subject,$a_m_message)
2002 include_once
"Services/Mail/classes/class.ilMailbox.php";
2005 $sent_id = $mbox->getSentFolder();
2007 return $this->
sendInternalMail($sent_id,$this->user_id,$a_attachment,$a_rcp_to,$a_rcp_cc,
2008 $a_rcp_bcc,
'read',$a_type,$a_as_email,$a_m_subject,$a_m_message,$this->user_id, 0);
2020 include_once
'Services/Mail/classes/class.ilMimeMail.php';
2035 include_once
"Services/Mail/classes/class.ilMimeMail.php";
2037 if($this->user_id != ANONYMOUS_USER_ID)
2062 include_once
'Services/Mail/classes/class.ilMimeMail.php';
2064 $no_reply_adress = trim($ilSetting->get(
'mail_external_sender_noreply'));
2065 if(strlen($no_reply_adress))
2067 if(strpos($no_reply_adress,
'@') ===
false)
2068 $no_reply_adress =
'noreply@'.$no_reply_adress;
2072 $no_reply_adress =
'noreply@'.$_SERVER[
'SERVER_NAME'];
2076 ' <'.$no_reply_adress.
'>';
2081 ' <noreply@'.$_SERVER[
'SERVER_NAME'].
'>';
2099 function sendMimeMail($a_rcp_to,$a_rcp_cc,$a_rcp_bcc,$a_m_subject,$a_m_message,$a_attachments)
2101 include_once
"Services/Mail/classes/class.ilMimeMail.php";
2103 #var_dump("<pre>",$a_rcp_to,$a_rcp_cc,$a_rcp_bcc,$a_m_subject,$a_m_message,$a_attachments,"<pre>");
2105 #$inst_name = $this->ilias->getSetting("inst_name") ? $this->ilias->getSetting("inst_name") : "ILIAS 4";
2106 #$a_m_subject = "[".$inst_name."] ".$a_m_subject;
2115 include_once
'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
2118 $soap_client->setTimeout(1);
2119 $soap_client->setResponseTimeout(1);
2120 $soap_client->enableWSDL(
true);
2121 $soap_client->init();
2123 $attachments = array();
2124 $a_attachments = $a_attachments ? $a_attachments : array();
2125 foreach($a_attachments as $attachment)
2127 $attachments[] = $this->mfile->getAbsolutePath($attachment);
2130 $attachments = implode(
'#:#',$attachments);
2132 if(strlen($attachments))
2133 $attachments =
"#:#".$attachments;
2135 $soap_client->call(
'sendMail',array(
$_COOKIE[
'PHPSESSID'].
'::'.
$_COOKIE[
'ilClientId'],
2149 include_once
"Services/Mail/classes/class.ilMimeMail.php";
2152 $mmail->autoCheck(
false);
2153 $mmail->From($sender);
2154 $mmail->To($a_rcp_to);
2156 $mmail->Subject($a_m_subject);
2157 $mmail->Body($a_m_message);
2161 $mmail->Cc($a_rcp_cc);
2166 $mmail->Bcc($a_rcp_bcc);
2169 if (is_array($a_attachments))
2171 foreach ($a_attachments as $attachment)
2173 $mmail->Attach($this->mfile->getAbsolutePath($attachment));
2188 $sender = $umail->getEmail();
2210 $ilDB->update($this->table_mail_saved,
2213 'attachments' => array(
'clob', serialize($a_attachments))
2217 'user_id' => array(
'integer', $this->user_id)
2231 return $this->mail_data[
"attachments"] ? $this->mail_data[
"attachments"] : array();
2251 if (strlen(trim($a_recipients)) > 0)
2253 require_once
'Mail/RFC822.php';
2255 return $parser->parseAddressList($a_recipients,
"ilias",
false,
true);
2262 $a_recipients = trim($a_recipients);
2265 #$a_recipients = preg_replace("/ /",",",$a_recipients);
2266 $a_recipients = preg_replace(
"/;/",
",",$a_recipients);
2269 foreach(explode(
',',$a_recipients) as $tmp_rec)
2273 $rcps[] = trim($tmp_rec);
2276 return is_array($rcps) ? $rcps : array();
2288 if (! is_a($tmp_rcp,
'PEAR_Error'))
2290 foreach ($tmp_rcp as $to)
2303 if ($to->host !=
'ilias' && substr($to->mailbox,0,1) !=
'#')
2322 if (strpos($to,
'@'))
2356 if (! is_a($tmp_rcp,
'PEAR_Error'))
2358 foreach ($tmp_rcp as $to)
2360 if(substr($to->mailbox,0,1) !=
'#' && $to->host !=
'ilias')
2368 $rcp[] = $to->mailbox.
'@'.$to->host;
2372 return implode(
',',$rcp);
2390 return implode(
',',$rcp ? $rcp : array());
2396 $inst_name = $this->ilias->getSetting(
"inst_name") ? $this->ilias->getSetting(
"inst_name") :
"ILIAS 3";
2398 $message = $inst_name.
" To:".$rcp_to.
"\n";
2402 $message .=
"Cc: ".$rcp_cc;
2406 $message .= $a_m_message;
2413 if (preg_match(
"/@all/",$a_rcp_to))
2417 $a_rcp_to = preg_replace(
"/@all/",implode(
',',$all),$a_rcp_to);
2432 $new_name = array();
2437 foreach($tmp_names as $name)
2439 if(strpos($name,
"#") === 0)
2441 $new_name[] = $name;
2449 $new_name[] = preg_replace(
"/@/",
"�#�",$name);
2453 $new_name[] = $name;
2457 case "resubstitute":
2458 if(stristr($name,
"�#�"))
2460 $new_name[] = preg_replace(
"/�#�/",
"@",$name);
2464 $new_name[] = $name;
2469 return implode(
",",$new_name);
2493 require_once
'./Services/User/classes/class.ilObjUser.php';
2496 $login = $usr_obj->getLogin();
2497 $firstname = $usr_obj->getFirstname();
2498 $lastname = $usr_obj->getLastname();
2508 return $login.
'hhho';
2526 if ($ilias->getSetting(
'pear_mail_enable') ==
true)
2531 $is_pear_mail_installed = @include_once
'Mail/RFC822.php';
2532 if ($is_pear_mail_installed) {
2538 $log->write(
"WARNING: ilMail::_userPearMail disabled Pear Mail support, because include 'Mail/RFC822.php' failed.");
2539 $ilias->setSetting(
'pear_mail_enable',
false);
2559 include_once(
'./Services/Language/classes/class.ilLanguageFactory.php');
2564 $lang->loadLanguageModule(
'mail');
2565 return sprintf(
$lang->txt(
'mail_auto_generated_info'),
2566 $ilSetting->get(
'inst_name',
'ILIAS 4'),
2578 public static function _getIliasMailerName()
2585 if(strlen($ilSetting->get(
'short_inst_name')))
2587 return $ilSetting->get(
'short_inst_name');
2603 if(null === $a_flag) {
2622 global $ilClientIniFile;
2624 $signature =
"\n\n* * * * *\n";
2625 $signature .= $ilClientIniFile->readVariable(
'client',
'name').
"\n";
2626 if(strlen($desc = $ilClientIniFile->readVariable(
'client',
'description')))
2628 $signature .= $desc.
"\n";
2634 if(is_array($clientdirs) && count($clientdirs) > 1)
2636 $signature .=
'/?client_id='.CLIENT_ID;
2649 static $prefix = null;
2651 return $prefix == null ? $ilSetting->get(
'mail_subject_prefix',
'') : $prefix;
2663 $lang = $a_language ? $a_language :
$lng;
2666 $gender = $gender ? $gender :
'n';
2669 if(!strlen($name[
'firstname']))
2671 return $lang->txt(
'mail_salutation_anonymous').
',';
2674 return $lang->txt(
'mail_salutation_'.$gender).
' '.
2675 ($name[
'title'] ? $name[
'title'].
' ' :
'').
2676 ($name[
'firstname'] ? $name[
'firstname'].
' ' :
'').
2677 $name[
'lastname'].
',';
2682 $this->use_pear = $bool;
2700 if(is_a($tmp_names,
'PEAR_Error'))