128 require_once
"Services/User/classes/class.ilObjUser.php";
238 require_once
"classes/class.ilFileDataMail.php";
239 require_once
"Services/Mail/classes/class.ilMailOptions.php";
240 require_once
"Services/Mail/classes/class.ilMailingLists.php";
244 $lng->loadLanguageModule(
"mail");
249 $this->table_mail =
'mail';
250 $this->table_mail_saved =
'mail_saved';
251 $this->user_id = $a_user_id;
254 if(is_object($ilUser))
269 if(self::_usePearMail())
272 if(is_a($recipients,
'PEAR_Error'))
278 foreach($recipients as $rcp)
280 if (substr($rcp->mailbox, 0, 1) !=
'#')
282 if(trim($rcp->mailbox) == trim($a_recipient) ||
283 trim($rcp->mailbox.
'@'.$rcp->host) == trim($a_recipient))
288 else if (substr($rcp->mailbox, 0, 7) ==
'#il_ml_')
290 if(trim($rcp->mailbox.
'@'.$rcp->host) == trim($a_recipient))
297 if(trim($rcp->mailbox.
'@'.$rcp->host) == trim($a_recipient))
308 if(count($recipients))
310 foreach($recipients as $recipient)
312 if(trim($recipient) == trim($a_recipient))
332 $this->soap_enabled = $a_status;
336 if(!extension_loaded(
'curl'))
346 $this->save_in_sentbox = $a_save_in_sentbox;
361 $this->mail_send_type = $a_types;
371 $this->mail_rcp_to = $a_rcp_to;
381 $this->mail_rcp_cc = $a_rcp_cc;
391 $this->mail_rcp_bc = $a_rcp_bc;
401 $this->mail_subject = $a_subject;
411 $this->mail_message = $a_message;
423 if (!MAIL_SETTINGS_ID)
425 $query =
"SELECT object_reference.ref_id FROM object_reference,tree,object_data ".
426 "WHERE tree.parent = ".$ilDB->quote(SYSTEM_FOLDER_ID).
" ".
427 "AND object_data.type = 'mail' ".
428 "AND object_reference.ref_id = tree.child ".
429 "AND object_reference.obj_id = object_data.obj_id";
430 $res = $this->ilias->db->query($query);
434 $this->mail_obj_ref_id = $row[
"ref_id"];
439 $this->mail_obj_ref_id = MAIL_SETTINGS_ID;
450 return $this->lng->txt(
'mail_notification_subject');
457 $tpl =&
new ilTemplate(
'tpl.mail_notifications.html',
true,
true,
'Services/Mail');
459 $tpl->setVariable(
'TXT_RECEIVED_MAILS', sprintf($this->lng->txt(
'mail_received_x_new_mails'), count(
$mail_data)));
464 $tpl->setCurrentBlock(
'mails');
465 $tpl->setVariable(
'NR', $counter + 1);
466 $tpl->setVariable(
'TXT_SENT', $this->lng->txt(
'sent'));
469 $tpl->setVariable(
'TXT_SUBJECT', $this->lng->txt(
'subject'));
470 $tpl->setVariable(
'SUBJECT', $mail[
'm_subject']);
471 $tpl->parseCurrentBlock();
493 $users = trim($users);
496 if(strstr($users,
','))
498 $rcp_to_array = array();
500 $recipients = explode(
',', $users);
501 foreach($recipients as $recipient)
503 $recipient = trim($recipient);
510 $rcp_to_array[] = $tmp_obj->getFullname().
' ['.$recipient.
']';
514 $rcp_to_array[] = $recipient;
520 $rcp_to_array[] = $recipient;
524 return trim(implode(
', ', $rcp_to_array));
533 return $tmp_obj->getFullname().
' ['.$users.
']';
549 return $this->lng->txt(
'not_available');
557 $query =
"SELECT b.* FROM " . $this->table_mail .
" AS a ".
558 "INNER JOIN ".$this->table_mail .
" AS b ON b.folder_id = a.folder_id AND b.user_id = a.user_id AND b.send_time > a.send_time ".
559 "WHERE a.user_id = ".$ilDB->quote($this->user_id) .
" ".
560 "AND a.mail_id = ".$ilDB->quote($a_mail_id).
" ORDER BY b.send_time ASC LIMIT 1";
571 $query =
"SELECT b.* FROM " . $this->table_mail .
" AS a ".
572 "INNER JOIN ".$this->table_mail .
" AS b ON b.folder_id = a.folder_id AND b.user_id = a.user_id AND b.send_time < a.send_time ".
573 "WHERE a.user_id = ".$ilDB->quote($this->user_id) .
" ".
574 "AND a.mail_id = ".$ilDB->quote($a_mail_id).
" ORDER BY b.send_time DESC LIMIT 1";
591 $this->mail_counter = array();
592 $this->mail_counter[
"read"] = 0;
593 $this->mail_counter[
"unread"] = 0;
595 $query =
"SELECT ".$this->table_mail.
".* FROM ". $this->table_mail .
" ".
596 "LEFT JOIN object_data ON obj_id = sender_id ".
597 "WHERE user_id = ".$ilDB->quote($this->user_id) .
" ".
598 "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)) ".
599 "AND folder_id = ".$ilDB->quote($a_folder_id).
" ORDER BY send_time DESC";
601 $res = $this->ilias->db->query($query);
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 $query =
"SELECT COUNT(*) FROM $this->table_mail ".
636 "WHERE user_id = ".$ilDB->quote($this->user_id) .
" ".
637 "AND folder_id = ".$ilDB->quote($a_folder_id).
" ";
639 if (is_object(
$res = $this->ilias->db->query($query)))
641 return $res->numRows();
659 $query =
"DELETE FROM $this->table_mail ".
660 "WHERE user_id = ".$ilDB->quote($this->user_id) .
" ".
661 "AND folder_id = ".$ilDB->quote($a_folder_id).
" ";
663 $res = $this->ilias->db->query($query);
679 return is_array($this->mail_counter) ? $this->mail_counter : array(
695 $query =
"SELECT * FROM $this->table_mail ".
696 "WHERE user_id = ".$ilDB->quote($this->user_id).
" ".
697 "AND mail_id = ".$ilDB->quote($a_mail_id).
" ";
716 $query =
"UPDATE $this->table_mail ".
717 "SET m_status = 'read' ".
718 "WHERE user_id = ".$ilDB->quote($this->user_id).
" ".
719 "AND mail_id IN $in";
721 $res = $this->ilias->db->query($query);
738 $query =
"UPDATE $this->table_mail ".
739 "SET m_status = 'unread' ".
740 "WHERE user_id = ".$ilDB->quote($this->user_id).
" ".
741 "AND mail_id IN $in";
743 $res = $this->ilias->db->query($query);
761 $query =
"UPDATE $this->table_mail ".
762 "SET folder_id = ".$ilDB->quote($a_folder_id).
" ".
763 "WHERE user_id = ".$ilDB->quote($this->user_id).
" ".
764 "AND mail_id IN $in";
766 $res = $this->ilias->db->query($query);
781 foreach ($a_mail_ids as $id)
783 $query =
"DELETE FROM $this->table_mail ".
784 "WHERE user_id = ".$ilDB->quote($this->user_id).
" ".
785 "AND mail_id = ".$ilDB->quote($id).
" ";
786 $res = $this->ilias->db->query($query);
787 $this->mfile->deassignAttachmentFromDirectory($id);
804 "mail_id" => $a_row->mail_id,
805 "user_id" => $a_row->user_id,
806 "folder_id" => $a_row->folder_id,
807 "sender_id" => $a_row->sender_id,
808 "attachments" => unserialize(stripslashes($a_row->attachments)),
809 "send_time" => $a_row->send_time,
810 "rcp_to" => $a_row->rcp_to,
811 "rcp_cc" => $a_row->rcp_cc,
812 "rcp_bcc" => $a_row->rcp_bcc,
813 "m_status" => $a_row->m_status,
814 "m_type" => unserialize(stripslashes($a_row->m_type)),
815 "m_email" => $a_row->m_email,
816 "m_subject" => $a_row->m_subject,
817 "m_message" => $a_row->m_message,
818 "import_name" => $a_row->import_name,
819 "use_placeholders"=> $a_row->use_placeholders);
831 $a_draft_id = 0, $a_use_placeholders = 0)
835 $query =
"UPDATE $this->table_mail ".
836 "SET folder_id = ".$ilDB->quote($a_folder_id).
",".
837 "attachments = '".addslashes(serialize($a_attachments)).
"',".
838 "send_time = now(),".
839 "rcp_to = ".$ilDB->quote($a_rcp_to).
",".
840 "rcp_cc = ".$ilDB->quote($a_rcp_cc).
",".
841 "rcp_bcc = ".$ilDB->quote($a_rcp_bcc).
",".
842 "m_status = 'read',".
843 "m_type = '".addslashes(serialize($a_m_type)).
"',".
844 "m_email = ".$ilDB->quote($a_m_email).
",".
845 "m_subject = ".$ilDB->quote($a_m_subject).
",".
846 "m_message = ".$ilDB->quote($a_m_message).
",".
847 "use_placeholders = ".$ilDB->quote($a_use_placeholders).
" ".
848 "WHERE mail_id = ".$ilDB->quote($a_draft_id).
"";
850 $res = $this->ilias->db->query($query);
883 $a_user_id = 0, $a_use_placeholders = 0)
890 if ($a_use_placeholders) $a_m_message = $this->
replacePlaceholders($a_m_message, $a_user_id);
892 $query =
"INSERT INTO $this->table_mail ".
893 "SET user_id = ".$ilDB->quote($a_user_id).
",".
894 "folder_id = ".$ilDB->quote($a_folder_id).
",".
895 "sender_id = ".$ilDB->quote($a_sender_id).
",".
896 "attachments = '".addslashes(serialize($a_attachments)).
"',".
897 "send_time = now(),".
898 "rcp_to = ".$ilDB->quote($a_rcp_to).
",".
899 "rcp_cc = ".$ilDB->quote($a_rcp_cc).
",".
900 "rcp_bcc = ".$ilDB->quote($a_rcp_bcc).
",".
901 "m_status = ".$ilDB->quote($a_status).
",".
902 "m_type = '".addslashes(serialize($a_m_type)).
"',".
903 "m_email = ".$ilDB->quote($a_m_email).
",".
904 "m_subject = ".$ilDB->quote($a_m_subject).
",".
905 "m_message = ".$ilDB->quote($a_m_message).
" ";
907 $res = $this->ilias->db->query($query);
908 $query =
"SELECT LAST_INSERT_ID() as id";
921 switch (
$user->getGender())
923 case 'f': $gender_salut = $lng->txt(
'salutation_f');
925 case 'm': $gender_salut = $lng->txt(
'salutation_m');
929 $a_message = str_replace(
'[MAIL_SALUTATION]', $gender_salut, $a_message);
930 $a_message = str_replace(
'[LOGIN]',
$user->getLogin(), $a_message);
931 $a_message = str_replace(
'[FIRST_NAME]',
$user->getFirstname(), $a_message);
932 $a_message = str_replace(
'[LAST_NAME]',
$user->getLastname(), $a_message);
933 $a_message = str_replace(
'[ILIAS_URL]', ILIAS_HTTP_PATH.
'/login.php?client_id='.CLIENT_ID, $a_message);
934 $a_message = str_replace(
'[CLIENT_NAME]', CLIENT_NAME, $a_message);
954 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)
958 include_once
'Services/Mail/classes/class.ilMailbox.php';
959 include_once
'./Services/User/classes/class.ilObjUser.php';
971 if (!$a_use_placeholders) # No Placeholders
973 $rcp_ids = $this->
getUserIds(trim($a_rcp_to).
','.trim($a_rcp_cc).
','.trim($a_rcp_bcc));
977 foreach($rcp_ids as $id)
984 $user_can_read_internal_mails = $tmp_user->hasAcceptedUserAgreement() &&
985 $tmp_user->getActive() &&
986 $tmp_user->checkTimeLimit();
989 if (in_array(
'system', $a_type) && !$user_can_read_internal_mails)
996 if (!$user_can_read_internal_mails ||
997 $tmp_mail_options->getIncomingType() == $this->mail_options->EMAIL)
1003 if ($tmp_mail_options->getIncomingType() == $this->mail_options->BOTH)
1008 $mbox->setUserId($id);
1009 $inbox_id = $mbox->getInboxFolder();
1012 $a_attachments, $a_rcp_to,
1013 $a_rcp_cc,
'',
'unread', $a_type,
1014 0, $a_subject, $a_message, $id, 0);
1017 $this->mfile->assignAttachmentsToDirectory($mail_id, $sent_mail_id, $a_attachments);
1025 if (count($as_email) == 1)
1031 foreach ($as_email as $id)
1037 if(count($to) > 0 || count($bcc) > 0)
1039 $this->
sendMimeMail(implode(
',', $to),
'', implode(
',', $bcc), $a_subject, $a_message, $a_attachments);
1042 else # Use Placeholders
1045 $rcp_ids_replace = $this->
getUserIds(trim($a_rcp_to));
1048 $rcp_ids_no_replace = $this->
getUserIds(trim($a_rcp_cc).
','.trim($a_rcp_bcc));
1050 $as_email = array();
1053 foreach($rcp_ids_replace as $id)
1060 $user_can_read_internal_mails = $tmp_user->hasAcceptedUserAgreement() &&
1061 $tmp_user->getActive() &&
1062 $tmp_user->checkTimeLimit();
1065 if (in_array(
'system', $a_type) && !$user_can_read_internal_mails)
1072 if (!$user_can_read_internal_mails ||
1073 $tmp_mail_options->getIncomingType() == $this->mail_options->EMAIL)
1079 if ($tmp_mail_options->getIncomingType() == $this->mail_options->BOTH)
1084 $mbox->setUserId($id);
1085 $inbox_id = $mbox->getInboxFolder();
1088 $a_attachments, $a_rcp_to,
1089 $a_rcp_cc,
'',
'unread', $a_type,
1090 0, $a_subject, $a_message, $id, 1);
1093 $this->mfile->assignAttachmentsToDirectory($mail_id, $sent_mail_id, $a_attachments);
1097 if (count($as_email))
1099 foreach ($as_email as $id)
1105 $as_email = array();
1108 foreach($rcp_ids_no_replace as $id)
1115 $user_can_read_internal_mails = $tmp_user->hasAcceptedUserAgreement()
1116 && $tmp_user->getActive() && $tmp_user->checkTimeLimit();
1119 if (in_array(
'system', $a_type) && !$user_can_read_internal_mails)
1126 if (!$user_can_read_internal_mails ||
1127 $tmp_mail_options->getIncomingType() == $this->mail_options->EMAIL)
1133 if ($tmp_mail_options->getIncomingType() == $this->mail_options->BOTH)
1138 $mbox->setUserId($id);
1139 $inbox_id = $mbox->getInboxFolder();
1142 $a_attachments, $a_rcp_to,
1143 $a_rcp_cc,
'',
'unread', $a_type,
1144 0, $a_subject, $a_message, $id, 0);
1147 $this->mfile->assignAttachmentsToDirectory($mail_id, $sent_mail_id, $a_attachments);
1151 if (count($as_email))
1153 foreach ($as_email as $id)
1170 global
$log, $rbacreview;
1176 if (! is_a($tmp_names,
'PEAR_Error'))
1178 for ($i = 0;$i < count($tmp_names); $i++)
1180 if (substr($tmp_names[$i]->mailbox,0,1) ===
'#')
1182 $role_ids = $rbacreview->searchRolesByMailboxAddressList($tmp_names[$i]->mailbox.
'@'.$tmp_names[$i]->host);
1183 foreach($role_ids as $role_id)
1185 foreach($rbacreview->assignedUsers($role_id) as $usr_id)
1191 else if (strtolower($tmp_names[$i]->host) ==
'ilias')
1217 for ($i = 0;$i < count($tmp_names); $i++)
1219 if (substr($tmp_names[$i],0,1) ==
'#')
1223 include_once(
"./classes/class.ilObjectFactory.php");
1224 include_once(
'./Modules/Group/classes/class.ilObjGroup.php');
1232 foreach ($grp_object->getGroupMemberIds() as $id)
1238 elseif($role_id = $rbacreview->roleExists(addslashes(substr($tmp_names[$i],1))))
1240 foreach($rbacreview->assignedUsers($role_id) as $usr_id)
1247 else if (!empty($tmp_names[$i]))
1256 return array_unique($ids);
1269 function checkMail($a_rcp_to,$a_rcp_cc,$a_rcp_bcc,$a_m_subject,$a_m_message,$a_type)
1271 $error_message =
'';
1273 $a_m_subject = trim($a_m_subject);
1274 $a_rcp_to = trim($a_rcp_to);
1276 if (empty($a_m_subject))
1278 $error_message .= $error_message ?
"<br>" :
'';
1279 $error_message .= $this->lng->txt(
"mail_add_subject");
1282 if (empty($a_rcp_to))
1284 $error_message .= $error_message ?
"<br>" :
'';
1285 $error_message .= $this->lng->txt(
"mail_add_recipient");
1288 return $error_message;
1299 $addresses = array();
1304 if (! is_a($tmp_rcp,
'PEAR_Error'))
1306 foreach ($tmp_rcp as $rcp)
1309 if (substr($rcp->mailbox,0,1) !=
'#')
1311 if (strtolower($rcp->host) !=
'ilias')
1313 $addresses[] = $rcp->mailbox.
'@'.$rcp->host;
1320 $addresses[] = $tmp_user->getEmail();
1327 $role_ids = $rbacreview->searchRolesByMailboxAddressList($rcp->mailbox.
'@'.$rcp->host);
1328 foreach($role_ids as $role_id)
1330 foreach($rbacreview->assignedUsers($role_id) as $usr_id)
1333 $addresses[] = $tmp_user->getEmail();
1344 foreach ($tmp_rcp as $rcp)
1347 if (substr($rcp,0,1) !=
'#')
1349 if (strpos($rcp,
'@'))
1351 $addresses[] = $rcp;
1358 $addresses[] = $tmp_user->getEmail();
1365 include_once(
"./classes/class.ilObjectFactory.php");
1366 include_once(
'./Modules/Group/classes/class.ilObjGroup.php');
1375 foreach ($grp_object->getGroupMemberIds() as $id)
1378 $addresses[] = $tmp_user->getEmail();
1396 global $rbacsystem,$rbacreview;
1402 if (is_a($tmp_rcp,
'PEAR_Error'))
1404 $colon_pos = strpos($tmp_rcp->message,
':');
1405 $wrong_rcps =
'<br />'.(($colon_pos ===
false) ? $tmp_rcp->message : substr($tmp_rcp->message, $colon_pos+2));
1409 foreach ($tmp_rcp as $rcp)
1412 if (substr($rcp->mailbox,0,1) !=
'#')
1416 if (
$user_id ==
false && $rcp->host ==
'ilias')
1418 $wrong_rcps .=
"<br />".htmlentities($rcp->mailbox);
1425 if(!$rbacsystem->checkAccessOfUser(
$user_id,
"mail_visible", $this->getMailObjectReferenceId()))
1427 $wrong_rcps .=
"<br />".htmlentities($rcp->mailbox).
1428 " (".$this->lng->txt(
"user_cant_receive_mail").
")";
1433 else if (substr($rcp->mailbox, 0, 7) ==
'#il_ml_')
1435 if (!$this->mlists->mailingListExists($rcp->mailbox))
1437 $wrong_rcps .=
"<br />".htmlentities($rcp->mailbox).
1438 " (".$this->lng->txt(
"mail_no_valid_mailing_list").
")";
1445 $role_ids = $rbacreview->searchRolesByMailboxAddressList($rcp->mailbox.
'@'.$rcp->host);
1446 if (count($role_ids) == 0)
1448 $wrong_rcps .=
'<br />'.htmlentities($rcp->mailbox).
1449 ' ('.$this->lng->txt(
'mail_no_recipient_found').
')';
1452 else if (count($role_ids) > 1)
1454 $wrong_rcps .=
'<br/>'.htmlentities($rcp->mailbox).
1455 ' ('.sprintf($this->lng->txt(
'mail_multiple_recipients_found'), implode(
',', $role_ids)).
')';
1465 foreach ($tmp_rcp as $rcp)
1472 if (substr($rcp,0,1) !=
'#')
1478 $wrong_rcps .=
"<br />".htmlentities($rcp);
1485 if(!$rbacsystem->checkAccessOfUser(
$user_id,
"mail_visible", $this->getMailObjectReferenceId()))
1487 $wrong_rcps .=
"<br />".htmlentities($rcp).
1488 " (".$this->lng->txt(
"user_cant_receive_mail").
")";
1493 else if (substr($rcp, 0, 7) ==
'#il_ml_')
1495 if (!$this->mlists->mailingListExists($rcp))
1497 $wrong_rcps .=
"<br />".htmlentities($rcp).
1498 " (".$this->lng->txt(
"mail_no_valid_mailing_list").
")";
1507 else if (!$rbacreview->roleExists(addslashes(substr($rcp,1))))
1509 $wrong_rcps .=
"<br />".htmlentities($rcp).
1510 " (".$this->lng->txt(
"mail_no_valid_group_role").
")";
1542 $a_use_placeholders)
1546 $query =
"DELETE FROM $this->table_mail_saved ".
1547 "WHERE user_id = ".$ilDB->quote($this->user_id).
" ";
1548 $res = $this->ilias->db->query($query);
1550 $query =
"INSERT INTO $this->table_mail_saved ".
1551 "SET user_id = ".$ilDB->quote($a_user_id).
",".
1552 "attachments = '".addslashes(serialize($a_attachments)).
"',".
1553 "rcp_to = ".$ilDB->quote($a_rcp_to).
",".
1554 "rcp_cc = ".$ilDB->quote($a_rcp_cc).
",".
1555 "rcp_bcc = ".$ilDB->quote($a_rcp_bcc).
",".
1556 "m_type = '".addslashes(serialize($a_m_type)).
"',".
1558 "m_subject = ".$ilDB->quote($a_m_subject).
",".
1559 "m_message = ".$ilDB->quote($a_m_message).
",".
1560 "use_placeholders = ".$ilDB->quote($a_use_placeholders).
"";
1561 $res = $this->ilias->db->query($query);
1577 $query =
"SELECT * FROM $this->table_mail_saved ".
1578 "WHERE user_id = ".$ilDB->quote($this->user_id).
" ";
1598 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)
1602 $error_message =
'';
1605 if (in_array(
"system",$a_type))
1608 $a_type = array(
'system');
1613 if (!$this->mfile->checkFilesExist($a_attachment))
1615 return "YOUR LIST OF ATTACHMENTS IS NOT VALID, PLEASE EDIT THE LIST";
1619 if ($error_message = $this->
checkMail($a_rcp_to,$a_rcp_cc,$a_rcp_bc,$a_m_subject,$a_m_message,$a_type))
1621 return $error_message;
1626 $message .= $error_message;
1631 $message .= $error_message;
1636 $message .= $error_message;
1639 if (!empty($message))
1641 return $this->lng->txt(
"mail_following_rcp_not_valid").$message;
1645 if (in_array(
'system',$a_type))
1647 if (!empty($a_attachment))
1649 return $lng->txt(
"mail_no_attach_allowed");
1683 if($c_emails && $this->user_id != ANONYMOUS_USER_ID &&
1684 !$rbacsystem->checkAccess(
'smtp_mail', $this->mail_obj_ref_id))
1686 return $this->lng->txt(
'mail_no_permissions_write_smtp');
1690 $sent_id = $this->
saveInSentbox($a_attachment,$a_rcp_to,$a_rcp_cc,$a_rcp_bc,$a_type,
1691 $a_m_subject,$a_m_message);
1695 $this->mfile->assignAttachmentsToDirectory($sent_id,$sent_id);
1697 if ($error = $this->mfile->saveFiles($sent_id,$a_attachment))
1716 if (in_array(
'system',$a_type))
1718 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))
1720 return $lng->txt(
"mail_send_error");
1724 if (in_array(
'normal',$a_type))
1727 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))
1729 return $lng->txt(
"mail_send_error");
1744 if ($rcpt ==
'')
return $rcpt;
1747 if (!is_array($arrRcpt) || empty($arrRcpt))
return $rcpt;
1749 $new_rcpt = array();
1751 foreach ($arrRcpt as $item)
1755 if (substr($item->mailbox, 0, 7) ==
'#il_ml_')
1757 if ($this->mlists->mailingListExists($item->mailbox))
1759 foreach ($this->mlists->getCurrentMailingList()->getAssignedEntries() as $entry)
1761 $new_rcpt[] = ($entry[
'login'] !=
'' ? $entry[
'login'] : $entry[
'email']);
1767 $new_rcpt[] = $item->mailbox.
'@'.$item->host;
1772 if (substr($item, 0, 7) ==
'#il_ml_')
1774 if ($this->mlists->mailingListExists($item))
1776 foreach ($this->mlists->getCurrentMailingList()->getAssignedEntries() as $entry)
1778 $new_rcpt[] = ($entry[
'login'] !=
'' ? $entry[
'login'] : $entry[
'email']);
1784 $new_rcpt[] = $item;
1789 return implode(
',', $new_rcpt);
1805 $a_m_subject,$a_m_message)
1807 include_once
"Services/Mail/classes/class.ilMailbox.php";
1810 $sent_id = $mbox->getSentFolder();
1812 return $this->
sendInternalMail($sent_id,$this->user_id,$a_attachment,$a_rcp_to,$a_rcp_cc,
1813 $a_rcp_bcc,
'read',$a_type,$a_as_email,$a_m_subject,$a_m_message,$this->user_id, 0);
1825 include_once
'Services/Mail/classes/class.ilMimeMail.php';
1844 function sendMimeMail($a_rcp_to,$a_rcp_cc,$a_rcp_bcc,$a_m_subject,$a_m_message,$a_attachments)
1846 #var_dump("<pre>",$a_rcp_to,$a_rcp_cc,$a_rcp_bcc,$a_m_subject,$a_m_message,$a_attachments,"<pre>");
1848 $inst_name = $this->ilias->getSetting(
"inst_name") ? $this->ilias->getSetting(
"inst_name") :
"ILIAS 3";
1849 $a_m_subject =
"[".$inst_name.
"] ".$a_m_subject;
1851 if($this->user_id != ANONYMOUS_USER_ID)
1857 if(trim($this->ilias->getSetting(
'mail_external_sender_noreply')) !=
'')
1859 include_once
"Services/Mail/classes/class.ilMimeMail.php";
1861 '<noreply@'.trim($this->ilias->getSetting(
'mail_external_sender_noreply')).
'>';
1865 include_once
"Services/Mail/classes/class.ilMimeMail.php";
1867 '<noreply@'.$_SERVER[
'SERVER_NAME'].
'>';
1874 include_once
'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
1877 $soap_client->setTimeout(1);
1878 $soap_client->setResponseTimeout(1);
1879 $soap_client->enableWSDL(
true);
1880 $soap_client->init();
1882 $attachments = array();
1883 $a_attachments = $a_attachments ? $a_attachments : array();
1884 foreach($a_attachments as $attachment)
1886 $attachments[] = $this->mfile->getAbsolutePath($attachment);
1889 $attachments = implode(
'#:#',$attachments);
1891 if(strlen($attachments))
1892 $attachments =
"#:#".$attachments;
1894 $soap_client->call(
'sendMail',array(
$_COOKIE[
'PHPSESSID'].
'::'.
$_COOKIE[
'ilClientId'],
1908 include_once
"Services/Mail/classes/class.ilMimeMail.php";
1911 $mmail->autoCheck(
false);
1912 $mmail->From($sender);
1913 $mmail->To($a_rcp_to);
1915 $mmail->Subject($a_m_subject);
1916 $mmail->Body($a_m_message);
1920 $mmail->Cc($a_rcp_cc);
1925 $mmail->Bcc($a_rcp_bcc);
1928 if (is_array($a_attachments))
1930 foreach ($a_attachments as $attachment)
1932 $mmail->Attach($this->mfile->getAbsolutePath($attachment));
1947 $sender = $umail->getEmail();
1969 $query =
"UPDATE $this->table_mail_saved ".
1970 "SET attachments = '".addslashes(serialize($a_attachments)).
"' ".
1971 "WHERE user_id = ".$ilDB->quote($this->user_id).
" ";
1973 $res = $this->ilias->db->query($query);
1985 return $this->mail_data[
"attachments"] ? $this->mail_data[
"attachments"] : array();
2005 if (strlen(trim($a_recipients)) > 0)
2007 require_once
'Mail/RFC822.php';
2008 $parser = &
new Mail_RFC822();
2009 return $parser->parseAddressList($a_recipients,
"ilias",
false,
true);
2016 $a_recipients = trim($a_recipients);
2019 #$a_recipients = preg_replace("/ /",",",$a_recipients);
2020 $a_recipients = preg_replace(
"/;/",
",",$a_recipients);
2023 foreach(explode(
',',$a_recipients) as $tmp_rec)
2027 $rcps[] = trim($tmp_rec);
2030 return is_array($rcps) ? $rcps : array();
2041 if (! is_a($tmp_rcp,
'PEAR_Error'))
2043 foreach ($tmp_rcp as $to)
2050 if ($to->host !=
'ilias' && substr($to->mailbox,0,1) !=
'#')
2068 if (strpos($to,
'@'))
2096 if (! is_a($tmp_rcp,
'PEAR_Error'))
2098 foreach ($tmp_rcp as $to)
2100 if(substr($to->mailbox,0,1) !=
'#' && $to->host !=
'ilias')
2102 $rcp[] = $to->mailbox.
'@'.$to->host;
2106 return implode(
',',$rcp);
2117 return implode(
',',$rcp ? $rcp : array());
2123 $inst_name = $this->ilias->getSetting(
"inst_name") ? $this->ilias->getSetting(
"inst_name") :
"ILIAS 3";
2125 $message = $inst_name.
" To:".$rcp_to.
"\n";
2129 $message .=
"Cc: ".$rcp_cc;
2133 $message .= $a_m_message;
2140 if (preg_match(
"/@all/",$a_rcp_to))
2144 $a_rcp_to = preg_replace(
"/@all/",implode(
',',$all),$a_rcp_to);
2159 $new_name = array();
2164 foreach($tmp_names as $name)
2166 if(strpos($name,
"#") === 0)
2168 $new_name[] = $name;
2176 $new_name[] = preg_replace(
"/@/",
"�#�",$name);
2180 $new_name[] = $name;
2184 case "resubstitute":
2185 if(stristr($name,
"�#�"))
2187 $new_name[] = preg_replace(
"/�#�/",
"@",$name);
2191 $new_name[] = $name;
2196 return implode(
",",$new_name);
2219 require_once
'./Services/User/classes/class.ilObjUser.php';
2222 $login = $usr_obj->getLogin();
2223 $firstname = $usr_obj->getFirstname();
2224 $lastname = $usr_obj->getLastname();
2234 return $login.
'hhho';
2251 if ($ilias->getSetting(
'pear_mail_enable') ==
true)
2256 $is_pear_mail_installed = @include_once
'Mail/RFC822.php';
2257 if ($is_pear_mail_installed) {
2263 $log->write(
"WARNING: ilMail::_userPearMail disabled Pear Mail support, because include 'Mail/RFC822.php' failed.");
2264 $ilias->setSetting(
'pear_mail_enable',
false);
2284 include_once(
'./Services/Language/classes/class.ilLanguageFactory.php');
2287 $lang->loadLanguageModule(
'mail');
2288 return sprintf(
$lang->txt(
'mail_auto_generated_info'),
2289 $ilSetting->get(
'inst_name',
'ILIAS 3'),
2290 ILIAS_HTTP_PATH.
"\n\n");