ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
ilMail Class Reference

Class Mail this class handles base functions for mail handling. More...

+ Inheritance diagram for ilMail:
+ Collaboration diagram for ilMail:

Public Member Functions

 __construct ($a_user_id)
 Constructor setup an mail object public. More...
 
 __get ($name)
 Magic interceptor method __get Used to include files / instantiate objects at runtime. More...
 
 doesRecipientStillExists ($a_recipient, $a_existing_recipients)
 
 enableSOAP ($a_status)
 
 isSOAPEnabled ()
 
 setSaveInSentbox ($a_save_in_sentbox)
 
 getSaveInSentbox ()
 
 setMailSendType ($a_types)
 
 setMailRcpTo ($a_rcp_to)
 
 setMailRcpCc ($a_rcp_cc)
 
 setMailRcpBc ($a_rcp_bc)
 
 setMailSubject ($a_subject)
 
 setMailMessage ($a_message)
 
 readMailObjectReferenceId ()
 read and set mail object id private More...
 
 getMailObjectReferenceId ()
 
 formatNamesForOutput ($users='')
 Prepends the fullname of each ILIAS login name (is user has a public profile) found in the passed string and brackets the ILIAS login name afterwards. More...
 
 getPreviousMail ($a_mail_id)
 
 getNextMail ($a_mail_id)
 
 getMailsOfFolder ($a_folder_id, $filter=array())
 get all mails of a specific folder public More...
 
 countMailsOfFolder ($a_folder_id)
 count all mails of a specific folder public More...
 
 deleteMailsOfFolder ($a_folder_id)
 delete all mails of a specific folder public More...
 
 getMailCounterData ()
 get mail counter data returns data array with indexes "total","read","unread" public More...
 
 getMail ($a_mail_id)
 get data of one mail public More...
 
 markRead ($a_mail_ids)
 mark mails as read public More...
 
 markUnread ($a_mail_ids)
 mark mails as unread public More...
 
 moveMailsToFolder ($a_mail_ids, $a_folder_id)
 move mail to folder public More...
 
 deleteMails ($a_mail_ids)
 delete mail public More...
 
 fetchMailData ($a_row)
 fetch all query data from table mail public More...
 
 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)
 
 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)
 save mail in folder private More...
 
 replacePlaceholders ($a_message, $a_user_id)
 
 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)
 send internal message to recipients private More...
 
 getUserIds ($a_recipients)
 get user_ids More...
 
 checkMail ($a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_m_subject, $a_m_message, $a_type)
 check if mail is complete, recipients are valid public More...
 
 getEmailsOfRecipients ($a_rcp)
 get email addresses of recipients public More...
 
 checkRecipients ($a_recipients, $a_type)
 check if recipients are valid public More...
 
 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)
 save post data in table public More...
 
 getSavedData ()
 get saved data public More...
 
 sendMail ($a_rcp_to, $a_rcp_cc, $a_rcp_bc, $a_m_subject, $a_m_message, $a_attachment, $a_type, $a_use_placeholders=0)
 send external mail using class.ilMimeMail.php More...
 
 parseRcptOfMailingLists ($rcpt='', $maintain_lists=false)
 
 saveInSentbox ($a_attachment, $a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_type, $a_m_subject, $a_m_message)
 send mime mail using class.ilMimeMail.php More...
 
 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 All external mails are send to SOAP::sendMail starting a kind of background process More...
 
 getEmailOfSender ()
 get email of sender public More...
 
 saveAttachments ($a_attachments)
 set attachments More...
 
 getAttachments ()
 get attachments public More...
 
 explodeRecipients ($a_recipients, $use_pear=true)
 explode recipient string allowed seperators are ',' ';' ' ' More...
 
 __getCountRecipient ($rcp, $a_only_email=true)
 
 __getCountRecipients ($a_to, $a_cc, $a_bcc, $a_only_email=true)
 
 __getEmailRecipients ($a_rcp)
 
 __prependMessage ($a_m_message, $rcp_to, $rcp_cc)
 
 __checkSystemRecipients (&$a_rcp_to)
 
 __substituteRecipients ($a_rcp, $direction)
 Note: This function can only be used, when ILIAS is configured to not use standards compliant mail addresses. More...
 
 appendInstallationSignature ($a_flag=null)
 Setter/Getter for appending the installation signarue. More...
 

Static Public Member Functions

static addFullname ($a_email, $a_fullname)
 
static getIliasMailerAddress ()
 Builds an email address used for system notifications. More...
 
static _getUserInternalMailboxAddress ($usr_id, $login=null, $firstname=null, $lastname=null)
 STATIC METHOD. More...
 
static _getAutoGeneratedMessageString ($lang=null)
 get auto generated info string More...
 
static _getInstallationSignature ()
 Static getter for the installation signature. More...
 
static getSubjectPrefix ()
 Get text that will be prepended to auto generated mails. More...
 
static getSalutation ($a_usr_id, $a_language=null)
 Get salutation. More...
 

Data Fields

 $ilias
 
 $lng
 
 $mfile
 
 $mail_options
 
 $user_id
 
 $table_mail
 
 $table_mail_saved
 
 $mail_counter
 
 $mail_data
 
 $mail_obj_ref_id
 
 $mail_send_type
 
 $save_in_sentbox
 
 $mail_rcp_to
 
 $mail_rcp_cc
 
 $mail_rcp_bc
 
 $mail_subject
 
 $mail_message
 
 $mail_use_placeholders = 0
 
 $soap_enabled = true
 
 $mail_to_global_roles = 0
 

Static Protected Member Functions

static getCachedUserInstance ($a_usr_id)
 Returns a cached instance of ilObjUser. More...
 

Protected Attributes

 $appendInstallationSignature = false
 
 $properties = array()
 

Static Protected Attributes

static $userInstances = array()
 

Private Member Functions

 setUsePear ($bool)
 
 getUsePear ()
 
 validatePear ($a_recipients)
 

Private Attributes

 $use_pear = true
 

Detailed Description

Class Mail this class handles base functions for mail handling.

RFC 822 compliant e-mail addresses

If ILIAS is configured to use standards compliant e-mail addresses, then this class supports RFC 822 compliant address lists as specified in http://www.ietf.org/rfc/rfc0822.txt

Examples: The following mailbox addresses work for sending an e-mail to the user with the login john.doe and e-mail address jd@ma.nosp@m.il.c.nosp@m.om. The user is member of the course "French Course". The member role of the course object has the name "il_crs_member_998" and the object ID "1000".

john.doe John Doe <john.doe> john.doe #member@[French Course] #il_crs_member_998 #il_role_1000 jd@ma.nosp@m.il.c.nosp@m.om John Doe jd@ma.nosp@m.il.c.nosp@m.om

Syntax Rules: The following excerpt from chapter 6.1 "Syntax" of RFC 822 is relevant for the semantics described below:

addr-spec = local-part [ "@", domain ]

Semantics: User account mailbox address:

  • The local-part denotes the login of an ILIAS user account.
  • The domain denotes the current ILIAS client.
  • The local-part must not start with a "#" character
  • The domain must be omitted or must have the value "ilias"

Role object mailbox address:

  • The local part denotes the title of an ILIAS role.
  • The domain denotes the title of an ILIAS object.
  • The local-part must start with a "#" character.
  • If the domain is omitted, the title "ilias" is assumed.
  • If the local-part starts with "#il_role_" its remaining characters directly specify the object id of the role. For example "#il_role_1234 identifies the role with object id "1234".
  • If the object title identifies an object that is an ILIAS role, then the local-part is ignored.
  • If the object title identifies an object that is not an ILIAS role, then the local-part is used to identify a local role for that object.
  • The local-part can be a substring of the role name. For example, "#member" can be used instead of "#il_crs_member_1234".

External E-Mail address:

  • The local-part must not start with a "#" character
  • The domain must be specified and it must not have the value "ilias"

Non-compliant e-mail addresses

If ILIAS is not configured to use standards compliant e-mail addresses, then the following description applies:

Examples: The following mailbox addresses work for sending an e-mail to the user with the login john.doe, who is member of the course "French Course". Assuming that the member role of the course object has the name "il_crs_member_998" and the object ID "1000".

john.doe #il_crs_member_998 #il_role_1000 jd@ma.nosp@m.il.c.nosp@m.om

Syntax: The following syntax rule is relevant for the semantics described below:

addr-spec = local-part [ "@", domain ]

Semantics: User account mailbox address:

  • The local-part denotes the login of an ILIAS user account.
  • The domain must be omitted.
  • The local-part must not start with a "#" character

Role object mailbox address:

  • The local part denotes the title of an ILIAS role.
  • The local-part must start with a "#" character.
  • The domain must be omitted.
  • If the local-part start with "#il_role_" its remaining characters directly specify the object id of the role. For example "#il_role_1234 identifies the role with object id "1234".

External E-Mail address:

  • The local-part must not start with a "#" character
  • The domain must be specified and it must not have the value "ilias"
Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 109 of file class.ilMail.php.

Constructor & Destructor Documentation

◆ __construct()

ilMail::__construct (   $a_user_id)

Constructor setup an mail object public.

Parameters
integeruser_id

Definition at line 231 of file class.ilMail.php.

References $ilias, $ilUser, $lng, readMailObjectReferenceId(), and setSaveInSentbox().

232  {
233  require_once "./Services/Mail/classes/class.ilFileDataMail.php";
234  require_once "Services/Mail/classes/class.ilMailOptions.php";
235 
236  global $ilias, $lng, $ilUser;
237 
238  $lng->loadLanguageModule("mail");
239 
240  // Initiate variables
241  $this->ilias =& $ilias;
242  $this->lng =& $lng;
243  $this->table_mail = 'mail';
244  $this->table_mail_saved = 'mail_saved';
245  $this->user_id = $a_user_id;
246  $this->mfile = new ilFileDataMail($this->user_id);
247  $this->mail_options = new ilMailOptions($a_user_id);
248 
249  // DEFAULT: sent mail aren't stored insentbox of user.
250  $this->setSaveInSentbox(false);
251 
252  // GET REFERENCE ID OF MAIL OBJECT
253  $this->readMailObjectReferenceId();
254  }
Class UserMail this class handles user mails.
This class handles all operations on files (attachments) in directory ilias_data/mail.
setSaveInSentbox($a_save_in_sentbox)
redirection script todo: (a better solution should control the processing via a xml file) ...
global $ilUser
Definition: imgupload.php:15
readMailObjectReferenceId()
read and set mail object id private
+ Here is the call graph for this function:

Member Function Documentation

◆ __checkSystemRecipients()

ilMail::__checkSystemRecipients ( $a_rcp_to)

Definition at line 2498 of file class.ilMail.php.

References ilObjUser\_getAllUserLogins().

Referenced by sendMail().

2499  {
2500  if (preg_match("/@all/",$a_rcp_to))
2501  {
2502  // GET ALL LOGINS
2503  $all = ilObjUser::_getAllUserLogins($this->ilias);
2504  $a_rcp_to = preg_replace("/@all/",implode(',',$all),$a_rcp_to);
2505  }
2506 
2507  return;
2508  }
redirection script todo: (a better solution should control the processing via a xml file) ...
_getAllUserLogins(&$ilias)
STATIC METHOD get all user logins.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __get()

ilMail::__get (   $name)

Magic interceptor method __get Used to include files / instantiate objects at runtime.

Parameters
stringThe name of the class property

Definition at line 263 of file class.ilMail.php.

References $ilUser.

264  {
265  global $ilUser;
266 
267  if(isset($this->properties[$name]))
268  {
269  return $this->properties[$name];
270  }
271 
272  // Used to include files / instantiate objects at runtime
273  if($name == 'mlists')
274  {
275  if(is_object($ilUser))
276  {
277  require_once 'Services/Contact/classes/class.ilMailingLists.php';
278  $this->properties[$name] = new ilMailingLists($ilUser);
279  return $this->properties[$name];
280  }
281  }
282  }
global $ilUser
Definition: imgupload.php:15

◆ __getCountRecipient()

ilMail::__getCountRecipient (   $rcp,
  $a_only_email = true 
)

Definition at line 2367 of file class.ilMail.php.

References __substituteRecipients(), ilObjUser\_lookupId(), explodeRecipients(), getUsePear(), and validatePear().

Referenced by __getCountRecipients().

2368  {
2369  $counter = 0;
2370 
2371  $this->validatePear($rcp);
2372  if (ilMail::_usePearMail() && $this->getUsePear())
2373  {
2374  $tmp_rcp = $this->explodeRecipients($rcp);
2375  if (! is_a($tmp_rcp, 'PEAR_Error'))
2376  {
2377  foreach ($tmp_rcp as $to)
2378  {
2379  if ($a_only_email)
2380  {
2381  // Fixed mantis bug #5875
2382  if(ilObjUser::_lookupId($to->mailbox.'@'.$to->host))
2383  {
2384  continue;
2385  }
2386 
2387  // Addresses which aren't on the ilias host, and
2388  // which have a mailbox which does not start with '#',
2389  // are external e-mail addresses
2390  if ($to->host != 'ilias' && substr($to->mailbox,0,1) != '#')
2391  {
2392  ++$counter;
2393  }
2394  }
2395  else
2396  {
2397  ++$counter;
2398  }
2399  }
2400  }
2401  }
2402  else
2403  {
2404  foreach ($this->explodeRecipients($rcp,$this->getUsePear()) as $to)
2405  {
2406  if ($a_only_email)
2407  {
2408  $to = $this->__substituteRecipients($to,"resubstitute");
2409  if (strpos($to,'@'))
2410  {
2411  // Fixed mantis bug #5875
2412  if(ilObjUser::_lookupId($to))
2413  {
2414  continue;
2415  }
2416 
2417  ++$counter;
2418  }
2419  }
2420  else
2421  {
2422  ++$counter;
2423  }
2424  }
2425  }
2426  return $counter;
2427  }
static _lookupId($a_user_str)
lookup id by login
explodeRecipients($a_recipients, $use_pear=true)
explode recipient string allowed seperators are &#39;,&#39; &#39;;&#39; &#39; &#39;
validatePear($a_recipients)
__substituteRecipients($a_rcp, $direction)
Note: This function can only be used, when ILIAS is configured to not use standards compliant mail ad...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __getCountRecipients()

ilMail::__getCountRecipients (   $a_to,
  $a_cc,
  $a_bcc,
  $a_only_email = true 
)

Definition at line 2430 of file class.ilMail.php.

References __getCountRecipient().

Referenced by sendMail().

2431  {
2432  return $this->__getCountRecipient($a_to,$a_only_email)
2433  + $this->__getCountRecipient($a_cc,$a_only_email)
2434  + $this->__getCountRecipient($a_bcc,$a_only_email);
2435  }
__getCountRecipient($rcp, $a_only_email=true)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __getEmailRecipients()

ilMail::__getEmailRecipients (   $a_rcp)

Definition at line 2437 of file class.ilMail.php.

References __substituteRecipients(), ilObjUser\_lookupId(), and explodeRecipients().

Referenced by sendMail().

2438  {
2439  if (ilMail::_usePearMail())
2440  {
2441  $rcp = array();
2442  $tmp_rcp = $this->explodeRecipients($a_rcp);
2443  if (! is_a($tmp_rcp, 'PEAR_Error'))
2444  {
2445  foreach ($tmp_rcp as $to)
2446  {
2447  if(substr($to->mailbox,0,1) != '#' && $to->host != 'ilias')
2448  {
2449  // Fixed mantis bug #5875
2450  if(ilObjUser::_lookupId($to->mailbox.'@'.$to->host))
2451  {
2452  continue;
2453  }
2454 
2455  $rcp[] = $to->mailbox.'@'.$to->host;
2456  }
2457  }
2458  }
2459  return implode(',',$rcp);
2460  }
2461  else
2462  {
2463  foreach ($this->explodeRecipients($a_rcp) as $to)
2464  {
2465  $to = $this->__substituteRecipients($to,"resubstitute");
2466  if(strpos($to,'@'))
2467  {
2468  // Fixed mantis bug #5875
2469  if(ilObjUser::_lookupId($to))
2470  {
2471  continue;
2472  }
2473 
2474  $rcp[] = $to;
2475  }
2476  }
2477  return implode(',',$rcp ? $rcp : array());
2478  }
2479  }
static _lookupId($a_user_str)
lookup id by login
explodeRecipients($a_recipients, $use_pear=true)
explode recipient string allowed seperators are &#39;,&#39; &#39;;&#39; &#39; &#39;
__substituteRecipients($a_rcp, $direction)
Note: This function can only be used, when ILIAS is configured to not use standards compliant mail ad...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __prependMessage()

ilMail::__prependMessage (   $a_m_message,
  $rcp_to,
  $rcp_cc 
)

Definition at line 2481 of file class.ilMail.php.

2482  {
2483  $inst_name = $this->ilias->getSetting("inst_name") ? $this->ilias->getSetting("inst_name") : "ILIAS 3";
2484 
2485  $message = $inst_name." To:".$rcp_to."\n";
2486 
2487  if ($rcp_cc)
2488  {
2489  $message .= "Cc: ".$rcp_cc;
2490  }
2491 
2492  $message .= "\n\n";
2493  $message .= $a_m_message;
2494 
2495  return $message;
2496  }
redirection script todo: (a better solution should control the processing via a xml file) ...

◆ __substituteRecipients()

ilMail::__substituteRecipients (   $a_rcp,
  $direction 
)

Note: This function can only be used, when ILIAS is configured to not use standards compliant mail addresses.

If standards compliant mail addresses are used, substitution is not supported, because then we do the parsing of mail addresses using the Pear Mail Extension.

Definition at line 2517 of file class.ilMail.php.

References ilObjUser\_loginExists(), and explodeRecipients().

Referenced by __getCountRecipient(), __getEmailRecipients(), distributeMail(), and sendMail().

2518  {
2519  $new_name = array();
2520 
2521  $tmp_names = $this->explodeRecipients($a_rcp);
2522 
2523 
2524  foreach($tmp_names as $name)
2525  {
2526  if(strpos($name,"#") === 0)
2527  {
2528  $new_name[] = $name;
2529  continue;
2530  }
2531  switch($direction)
2532  {
2533  case "substitute":
2534  if(strpos($name,"@") and ilObjUser::_loginExists($name))
2535  {
2536  $new_name[] = preg_replace("/@/","�#�",$name);
2537  }
2538  else
2539  {
2540  $new_name[] = $name;
2541  }
2542  break;
2543 
2544  case "resubstitute":
2545  if(stristr($name,"�#�"))
2546  {
2547  $new_name[] = preg_replace("/�#�/","@",$name);
2548  }
2549  else
2550  {
2551  $new_name[] = $name;
2552  }
2553  break;
2554  }
2555  }
2556  return implode(",",$new_name);
2557  }
explodeRecipients($a_recipients, $use_pear=true)
explode recipient string allowed seperators are &#39;,&#39; &#39;;&#39; &#39; &#39;
static _loginExists($a_login, $a_user_id=0)
check if a login name already exists You may exclude a user from the check by giving his user id as 2...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getAutoGeneratedMessageString()

static ilMail::_getAutoGeneratedMessageString (   $lang = null)
static

get auto generated info string

public

Parameters
stringlanguage

Definition at line 2625 of file class.ilMail.php.

References $ilSetting, $lang, ilUtil\_getHttpPath(), and ilLanguageFactory\_getLanguage().

Referenced by ilECSAppEventListener\_sendNotification(), ilSystemNotification\compose(), ilPaymentNotification\send(), ilMailSummaryNotification\send(), ilECSObjectSettings\sendNewContentNotification(), ilRemoteObjectBase\sendNewContentNotification(), and ilAuthContainerECS\sendNotification().

2626  {
2627  global $ilSetting;
2628 
2629  if(!$lang)
2630  {
2631  include_once('./Services/Language/classes/class.ilLanguageFactory.php');
2633  }
2634  $http_path = ilUtil::_getHttpPath();
2635 
2636  $lang->loadLanguageModule('mail');
2637  return sprintf($lang->txt('mail_auto_generated_info'),
2638  $ilSetting->get('inst_name','ILIAS 4'),
2639  $http_path)."\n\n";
2640  }
static _getLanguage($a_lang_key='')
Get langauge object.
static _getHttpPath()
global $ilSetting
Definition: privfeed.php:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getInstallationSignature()

static ilMail::_getInstallationSignature ( )
static

Static getter for the installation signature.

public

Returns
string The installation mail signature

Definition at line 2694 of file class.ilMail.php.

References ilUtil\_getHttpPath(), and ILIAS_WEB_DIR.

Referenced by ilRegistrationMimeMailNotification\__construct(), ilForum\__formatMessage(), ilSystemNotification\compose(), ilPaymentNotification\send(), and ilMailSummaryNotification\send().

2695  {
2696  global $ilClientIniFile;
2697 
2698  $signature = "\n\n* * * * *\n";
2699 
2700  $signature .= $ilClientIniFile->readVariable('client', 'name')."\n";
2701  if(strlen($desc = $ilClientIniFile->readVariable('client', 'description')))
2702  {
2703  $signature .= $desc."\n";
2704  }
2705 
2706  $signature .= ilUtil::_getHttpPath();
2707 
2708  $clientdirs = glob(ILIAS_WEB_DIR."/*", GLOB_ONLYDIR);
2709  if(is_array($clientdirs) && count($clientdirs) > 1)
2710  {
2711  $signature .= '/?client_id='.CLIENT_ID;
2712  }
2713 
2714  $signature .= "\n\n";
2715 
2716  return $signature;
2717  }
const ILIAS_WEB_DIR
static _getHttpPath()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getUserInternalMailboxAddress()

static ilMail::_getUserInternalMailboxAddress (   $usr_id,
  $login = null,
  $firstname = null,
  $lastname = null 
)
static

STATIC METHOD.

Returns the internal mailbox address for the specified user.

This functions (may) perform faster, if the login, firstname and lastname are supplied as parameters aloing with the $usr_id.

Parameters
usr_idthe usr_id of the user
loginoptional, but if you supply it, you have to supply the firstname and the lastname as well
firstnameoptional
lastnamepublic

Definition at line 2574 of file class.ilMail.php.

References $ilSetting, and $usr_id.

2575  {
2576  if (ilMail::_usePearMail())
2577  {
2578  if ($login == null)
2579  {
2580  require_once './Services/User/classes/class.ilObjUser.php';
2581  $usr_obj = self::getCachedUserInstance($usr_id);
2582  $login = $usr_obj->getLogin();
2583  $firstname = $usr_obj->getFirstname();
2584  $lastname = $usr_obj->getLastname();
2585  }
2586  // The following line of code creates a properly formatted mailbox
2587  // address. Unfortunately, it does not work, because ILIAS removes
2588  // everything between '<' '>' characters
2589  // Therefore, we just return the login - sic.
2590  // FIXME - Make this work in a future release
2591  /*
2592  return preg_replace('/[()<>@,;:\\".\[\]]/','',$firstname.' '.$lastname).' <'.$login.'>';
2593  */
2594  return $login.'hhho';
2595  }
2596  else
2597  {
2598  return $login;
2599  }
2600  }

◆ addFullname()

static ilMail::addFullname (   $a_email,
  $a_fullname 
)
static
Parameters
string$a_email
string$a_fullname
Returns
string

Definition at line 2094 of file class.ilMail.php.

References $ilUser, $user_id, and ilMimeMail\_mimeEncode().

2095  {
2096  include_once 'Services/Mail/classes/class.ilMimeMail.php';
2097  return ilMimeMail::_mimeEncode($a_fullname).' <'.$a_email.'>';
2098  }
_mimeEncode($a_string)
+ Here is the call graph for this function:

◆ appendInstallationSignature()

ilMail::appendInstallationSignature (   $a_flag = null)

Setter/Getter for appending the installation signarue.

public

Parameters
mixedboolean or nothing
Returns
mixed boolean if called without passing any params, otherwise $this

Definition at line 2675 of file class.ilMail.php.

References $appendInstallationSignature.

Referenced by sendMail().

2676  {
2677  if(null === $a_flag) {
2679  }
2680 
2681  $this->appendInstallationSignature = $a_flag;
2682 
2683  return $this;
2684  }
$appendInstallationSignature
appendInstallationSignature($a_flag=null)
Setter/Getter for appending the installation signarue.
+ Here is the caller graph for this function:

◆ checkMail()

ilMail::checkMail (   $a_rcp_to,
  $a_rcp_cc,
  $a_rcp_bcc,
  $a_m_subject,
  $a_m_message,
  $a_type 
)

check if mail is complete, recipients are valid public

Parameters
stringrcp_to
stringrcp_cc
stringrcp_bcc
stringm_subject
stringm_message
Returns
string error message

Definition at line 1385 of file class.ilMail.php.

Referenced by sendMail().

1386  {
1387  $error_message = '';
1388 
1389  $a_m_subject = trim($a_m_subject);
1390  $a_rcp_to = trim($a_rcp_to);
1391 
1392  if (empty($a_m_subject))
1393  {
1394  $error_message .= $error_message ? "<br>" : '';
1395  $error_message .= $this->lng->txt("mail_add_subject");
1396  }
1397 
1398  if (empty($a_rcp_to))
1399  {
1400  $error_message .= $error_message ? "<br>" : '';
1401  $error_message .= $this->lng->txt("mail_add_recipient");
1402  }
1403 
1404  return $error_message;
1405  }
+ Here is the caller graph for this function:

◆ checkRecipients()

ilMail::checkRecipients (   $a_recipients,
  $a_type 
)

check if recipients are valid public

Parameters
stringstring with login names or group names (start with #)
Returns
Returns an empty string, if all recipients are okay. Returns a string with invalid recipients, if some are not okay.

Definition at line 1513 of file class.ilMail.php.

References explodeRecipients(), getUsePear(), ilObjUser\getUserIdByLogin(), ilUtil\groupNameExists(), ilUtil\is_email(), and validatePear().

Referenced by sendMail().

1514  {
1515  global $rbacsystem,$rbacreview;
1516  $wrong_rcps = '';
1517 
1518  $this->validatePear($a_recipients);
1519  if (ilMail::_usePearMail() && $this->getUsePear())
1520  {
1521  $tmp_rcp = $this->explodeRecipients($a_recipients, $this->getUsePear());
1522 
1523  if (is_a($tmp_rcp, 'PEAR_Error'))
1524  {
1525  $colon_pos = strpos($tmp_rcp->message, ':');
1526  $wrong_rcps = '<br />'.(($colon_pos === false) ? $tmp_rcp->message : substr($tmp_rcp->message, $colon_pos+2));
1527  }
1528  else
1529  {
1530  foreach ($tmp_rcp as $rcp)
1531  {
1532  // NO ROLE MAIL ADDRESS
1533  if (substr($rcp->mailbox,0,1) != '#')
1534  {
1535  // ALL RECIPIENTS MUST EITHER HAVE A VALID LOGIN OR A VALID EMAIL
1536  $user_id = ($rcp->host == 'ilias') ? ilObjUser::getUserIdByLogin(addslashes($rcp->mailbox)) : false;
1537  if ($user_id == false && $rcp->host == 'ilias')
1538  {
1539  $wrong_rcps .= "<br />".htmlentities($rcp->mailbox);
1540  continue;
1541  }
1542 
1543  // CHECK IF USER CAN RECEIVE MAIL
1544  if ($user_id)
1545  {
1546  if(!$rbacsystem->checkAccessOfUser($user_id, "internal_mail", $this->getMailObjectReferenceId()))
1547  {
1548  $wrong_rcps .= "<br />".htmlentities($rcp->mailbox).
1549  " (".$this->lng->txt("user_cant_receive_mail").")";
1550  continue;
1551  }
1552  }
1553  }
1554  else if (substr($rcp->mailbox, 0, 7) == '#il_ml_')
1555  {
1556  if (!$this->mlists->mailingListExists($rcp->mailbox))
1557  {
1558  $wrong_rcps .= "<br />".htmlentities($rcp->mailbox).
1559  " (".$this->lng->txt("mail_no_valid_mailing_list").")";
1560  }
1561 
1562  continue;
1563  }
1564  else
1565  {
1566 
1567  $role_ids = $rbacreview->searchRolesByMailboxAddressList($rcp->mailbox.'@'.$rcp->host);
1568 
1569  if(!$this->mail_to_global_roles && is_array($role_ids))
1570  {
1571  foreach($role_ids as $role_id)
1572  {
1573  if($rbacreview->isGlobalRole($role_id))
1574  {
1575  include_once('Services/Mail/exceptions/class.ilMailException.php');
1576  throw new ilMailException('mail_to_global_roles_not_allowed');
1577 
1578  }
1579  }
1580  }
1581  if (count($role_ids) == 0)
1582  {
1583  $wrong_rcps .= '<br />'.htmlentities($rcp->mailbox).
1584  ' ('.$this->lng->txt('mail_no_recipient_found').')';
1585  continue;
1586  }
1587  else if (count($role_ids) > 1)
1588  {
1589  $wrong_rcps .= '<br/>'.htmlentities($rcp->mailbox).
1590  ' ('.sprintf($this->lng->txt('mail_multiple_recipients_found'), implode(',', $role_ids)).')';
1591  }
1592  }
1593  }
1594  }
1595  }
1596  else // NO PEAR
1597  {
1598  $tmp_rcp = $this->explodeRecipients($a_recipients, $this->getUsePear());
1599 
1600  foreach ($tmp_rcp as $rcp)
1601  {
1602  if (empty($rcp))
1603  {
1604  continue;
1605  }
1606  // NO GROUP
1607  if (substr($rcp,0,1) != '#')
1608  {
1609  // ALL RECIPIENTS MUST EITHER HAVE A VALID LOGIN OR A VALID EMAIL
1610  if (!ilObjUser::getUserIdByLogin(addslashes($rcp)) and
1611  !ilUtil::is_email($rcp))
1612  {
1613  $wrong_rcps .= "<br />".htmlentities($rcp);
1614  continue;
1615  }
1616 
1617  // CHECK IF USER CAN RECEIVE MAIL
1618  if ($user_id = ilObjUser::getUserIdByLogin(addslashes($rcp)))
1619  {
1620  if(!$rbacsystem->checkAccessOfUser($user_id, "internal_mail", $this->getMailObjectReferenceId()))
1621  {
1622  $wrong_rcps .= "<br />".htmlentities($rcp).
1623  " (".$this->lng->txt("user_cant_receive_mail").")";
1624  continue;
1625  }
1626  }
1627  }
1628  else if (substr($rcp, 0, 7) == '#il_ml_')
1629  {
1630  if (!$this->mlists->mailingListExists($rcp))
1631  {
1632  $wrong_rcps .= "<br />".htmlentities($rcp).
1633  " (".$this->lng->txt("mail_no_valid_mailing_list").")";
1634  }
1635 
1636  continue;
1637  }
1638  else if (ilUtil::groupNameExists(addslashes(substr($rcp,1))))
1639  {
1640  continue;
1641  }
1642  else if (!$rbacreview->roleExists(addslashes(substr($rcp,1))))
1643  {
1644  $wrong_rcps .= "<br />".htmlentities($rcp).
1645  " (".$this->lng->txt("mail_no_valid_group_role").")";
1646  continue;
1647  }
1648  else if (!$this->mail_to_global_roles)
1649  {
1650  $role_id = $rbacreview->roleExists(addslashes(substr($rcp,1)));
1651  if((int)$role_id && $rbacreview->isGlobalRole($role_id))
1652  {
1653  include_once('Services/Mail/exceptions/class.ilMailException.php');
1654  throw new ilMailException('mail_to_global_roles_not_allowed');
1655  }
1656  }
1657  }
1658  }
1659  return $wrong_rcps;
1660  }
static is_email($a_email)
This preg-based function checks whether an e-mail address is formally valid.
ILIAS Exception for Service Mail.
static groupNameExists($a_group_name, $a_id=0)
checks if group name already exists.
explodeRecipients($a_recipients, $use_pear=true)
explode recipient string allowed seperators are &#39;,&#39; &#39;;&#39; &#39; &#39;
validatePear($a_recipients)
getUserIdByLogin($a_login)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ countMailsOfFolder()

ilMail::countMailsOfFolder (   $a_folder_id)

count all mails of a specific folder public

Parameters
integerid of folder
Returns
bool number of mails

Definition at line 626 of file class.ilMail.php.

References $res.

627  {
628  global $ilDB;
629 
630  $res = $ilDB->queryf("
631  SELECT COUNT(*) FROM ". $this->table_mail ."
632  WHERE user_id = %s
633  AND folder_id = %s",
634  array('integer', 'integer'),
635  array($this->user_id, $a_folder_id));
636 
637  return $res->numRows();
638  }

◆ deleteMails()

ilMail::deleteMails (   $a_mail_ids)

delete mail public

Parameters
arraymail ids
Returns
bool

Definition at line 852 of file class.ilMail.php.

Referenced by deleteMailsOfFolder(), and sendMail().

853  {
854  global $ilDB;
855 
856  foreach ($a_mail_ids as $id)
857  {
858  $statement = $ilDB->manipulateF("
859  DELETE FROM ". $this->table_mail ."
860  WHERE user_id = %s
861  AND mail_id = %s ",
862  array('integer', 'integer'),
863  array($this->user_id, $id));
864 
865  $this->mfile->deassignAttachmentFromDirectory($id);
866  }
867 
868  return true;
869  }
+ Here is the caller graph for this function:

◆ deleteMailsOfFolder()

ilMail::deleteMailsOfFolder (   $a_folder_id)

delete all mails of a specific folder public

Parameters
integerid of folder

Definition at line 646 of file class.ilMail.php.

References deleteMails(), and getMailsOfFolder().

647  {
648  if ($a_folder_id)
649  {
650  global $ilDB;
651 
652  /*$statement = $ilDB->manipulateF("
653  DELETE FROM ". $this->table_mail ."
654  WHERE user_id = %s
655  AND folder_id = %s",
656  array('integer', 'integer'),
657  array($this->user_id, $a_folder_id));*/
658  $mails = $this->getMailsOfFolder($a_folder_id);
659  foreach((array)$mails as $mail_data)
660  {
661  $this->deleteMails(array($mail_data['mail_id']));
662  }
663 
664  return true;
665  }
666 
667  return false;
668  }
getMailsOfFolder($a_folder_id, $filter=array())
get all mails of a specific folder public
deleteMails($a_mail_ids)
delete mail public
+ Here is the call graph for this function:

◆ distributeMail()

ilMail::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 
)

send internal message to recipients private

Parameters
stringto
stringcc
stringbcc
stringsubject
stringmessage
arrayattachments
integerid of mail which is stored in sentbox
array'normal' and/or 'system' and/or 'email'
Returns
bool

Definition at line 1056 of file class.ilMail.php.

References $log, __substituteRecipients(), getUserIds(), replacePlaceholders(), sendInternalMail(), and sendMimeMail().

Referenced by sendMail().

1057  {
1058  global $log;
1059 
1060  include_once 'Services/Mail/classes/class.ilMailbox.php';
1061  include_once './Services/User/classes/class.ilObjUser.php';
1062 
1063  if (!ilMail::_usePearMail())
1064  {
1065  // REPLACE ALL LOGIN NAMES WITH '@' BY ANOTHER CHARACTER
1066  $a_rcp_to = $this->__substituteRecipients($a_rcp_to, 'resubstitute');
1067  $a_rcp_cc = $this->__substituteRecipients($a_rcp_cc, 'resubstitute');
1068  $a_rcp_bcc = $this->__substituteRecipients($a_rcp_bcc, 'resubstitute');
1069  }
1070 
1071  $mbox = new ilMailbox();
1072 
1073  if (!$a_use_placeholders) # No Placeholders
1074  {
1075  $rcp_ids = $this->getUserIds(trim($a_rcp_to).','.trim($a_rcp_cc).','.trim($a_rcp_bcc));
1076 
1077  $as_email = array();
1078 
1079  foreach($rcp_ids as $id)
1080  {
1081  $tmp_mail_options = new ilMailOptions($id);
1082 
1083  // DETERMINE IF THE USER CAN READ INTERNAL MAILS
1084  $tmp_user = self::getCachedUserInstance($id);
1085  $user_is_active = $tmp_user->getActive();
1086  $user_can_read_internal_mails = !$tmp_user->hasToAcceptTermsOfService() && $tmp_user->checkTimeLimit();
1087 
1088  // CONTINUE IF SYSTEM MESSAGE AND USER CAN'T READ INTERNAL MAILS
1089  if (in_array('system', $a_type) && !$user_can_read_internal_mails)
1090  {
1091  continue;
1092  }
1093 
1094  // CONTINUE IF USER CAN'T READ INTERNAL MAILS OR IF HE/SHE WANTS HIS/HER MAIL
1095  // SENT TO HIS/HER EXTERNAL E-MAIL ADDRESS ONLY
1096 
1097  // Do not send external mails to inactive users!!!
1098  if($user_is_active)
1099  {
1100  if (!$user_can_read_internal_mails ||
1101  $tmp_mail_options->getIncomingType() == $this->mail_options->EMAIL)
1102  {
1103  $as_email[] = $tmp_user->getEmail();
1104  continue;
1105  }
1106 
1107  if ($tmp_mail_options->getIncomingType() == $this->mail_options->BOTH)
1108  {
1109  $as_email[] = $tmp_user->getEmail();
1110  }
1111  }
1112  $mbox->setUserId($id);
1113  $inbox_id = $mbox->getInboxFolder();
1114 
1115  $mail_id = $this->sendInternalMail($inbox_id, $this->user_id,
1116  $a_attachments, $a_rcp_to,
1117  $a_rcp_cc, '', 'unread', $a_type,
1118  0, $a_subject, $a_message, $id, 0);
1119  if ($a_attachments)
1120  {
1121  $this->mfile->assignAttachmentsToDirectory($mail_id, $sent_mail_id, $a_attachments);
1122  }
1123  }
1124 
1125  // SEND EMAIL TO ALL USERS WHO DECIDED 'email' or 'both'
1126  $to = array();
1127  $bcc = array();
1128 
1129  if(count($as_email) == 1)
1130  {
1131  $to[] = $as_email[0];
1132  }
1133  else
1134  {
1135  foreach ($as_email as $email)
1136  {
1137  $bcc[] = $email;
1138  }
1139  }
1140 
1141  if(count($to) > 0 || count($bcc) > 0)
1142  {
1143  $this->sendMimeMail(implode(',', $to), '', implode(',', $bcc), $a_subject, $a_message, $a_attachments);
1144  }
1145  }
1146  else # Use Placeholders
1147  {
1148  // to
1149  $rcp_ids_replace = $this->getUserIds(trim($a_rcp_to));
1150 
1151  // cc / bcc
1152  $rcp_ids_no_replace = $this->getUserIds(trim($a_rcp_cc).','.trim($a_rcp_bcc));
1153 
1154  $as_email = array();
1155 
1156  // to
1157  foreach($rcp_ids_replace as $id)
1158  {
1159  $tmp_mail_options = new ilMailOptions($id);
1160 
1161  // DETERMINE IF THE USER CAN READ INTERNAL MAILS
1162  $tmp_user = self::getCachedUserInstance($id);
1163  $user_is_active = $tmp_user->getActive();
1164  $user_can_read_internal_mails = !$tmp_user->hasToAcceptTermsOfService() && $tmp_user->checkTimeLimit();
1165 
1166  // CONTINUE IF SYSTEM MESSAGE AND USER CAN'T READ INTERNAL MAILS
1167  if (in_array('system', $a_type) && !$user_can_read_internal_mails)
1168  {
1169  continue;
1170  }
1171 
1172  // CONTINUE IF USER CAN'T READ INTERNAL MAILS OR IF HE/SHE WANTS HIS MAIL
1173  // SENT TO HIS/HER EXTERNAL E-MAIL ADDRESS ONLY
1174 
1175  // Do not send external mails to inactive users!!!
1176  if($user_is_active)
1177  {
1178  if (!$user_can_read_internal_mails ||
1179  $tmp_mail_options->getIncomingType() == $this->mail_options->EMAIL)
1180  {
1181  $as_email[$tmp_user->getId()] = $tmp_user->getEmail();
1182  continue;
1183  }
1184 
1185  if ($tmp_mail_options->getIncomingType() == $this->mail_options->BOTH)
1186  {
1187  $as_email[$tmp_user->getId()] = $tmp_user->getEmail();
1188  }
1189  }
1190  $mbox->setUserId($id);
1191  $inbox_id = $mbox->getInboxFolder();
1192 
1193  $mail_id = $this->sendInternalMail($inbox_id, $this->user_id,
1194  $a_attachments, $a_rcp_to,
1195  $a_rcp_cc, '', 'unread', $a_type,
1196  0, $a_subject, $a_message, $id, 1);
1197  if ($a_attachments)
1198  {
1199  $this->mfile->assignAttachmentsToDirectory($mail_id, $sent_mail_id, $a_attachments);
1200  }
1201  }
1202 
1203  if (count($as_email))
1204  {
1205  foreach ($as_email as $id => $email)
1206  {
1207  $this->sendMimeMail($email, '', '', $a_subject, $this->replacePlaceholders($a_message, $id), $a_attachments);
1208  }
1209  }
1210 
1211  $as_email = array();
1212 
1213  // cc / bcc
1214  foreach($rcp_ids_no_replace as $id)
1215  {
1216  $tmp_mail_options = new ilMailOptions($id);
1217 
1218  // DETERMINE IF THE USER CAN READ INTERNAL MAILS
1219  $tmp_user = self::getCachedUserInstance($id);
1220  $user_is_active = $tmp_user->getActive();
1221  $user_can_read_internal_mails = !$tmp_user->hasToAcceptTermsOfService() && $tmp_user->checkTimeLimit();
1222 
1223  // Do not send external mails to inactive users!!!
1224  if($user_is_active)
1225  {
1226  // CONTINUE IF SYSTEM MESSAGE AND USER CAN'T READ INTERNAL MAILS
1227  if (in_array('system', $a_type) && !$user_can_read_internal_mails)
1228  {
1229  continue;
1230  }
1231 
1232  // CONTINUE IF USER CAN'T READ INTERNAL MAILS OR IF HE/SHE WANTS HIS MAIL
1233  // SENT TO HIS/HER EXTERNAL E-MAIL ADDRESS ONLY
1234  if (!$user_can_read_internal_mails ||
1235  $tmp_mail_options->getIncomingType() == $this->mail_options->EMAIL)
1236  {
1237  $as_email[] = $tmp_user->getEmail();
1238  continue;
1239  }
1240 
1241  if ($tmp_mail_options->getIncomingType() == $this->mail_options->BOTH)
1242  {
1243  $as_email[] = $tmp_user->getEmail();
1244  }
1245  }
1246  $mbox->setUserId($id);
1247  $inbox_id = $mbox->getInboxFolder();
1248 
1249  $mail_id = $this->sendInternalMail($inbox_id, $this->user_id,
1250  $a_attachments, $a_rcp_to,
1251  $a_rcp_cc, '', 'unread', $a_type,
1252  0, $a_subject, $a_message, $id, 0);
1253  if ($a_attachments)
1254  {
1255  $this->mfile->assignAttachmentsToDirectory($mail_id, $sent_mail_id, $a_attachments);
1256  }
1257  }
1258 
1259  if (count($as_email))
1260  {
1261  $this->sendMimeMail('', '', implode(',', $as_email), $a_subject, $a_message, $a_attachments);
1262  }
1263  }
1264 
1265  return true;
1266  }
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)
save mail in folder private
Class UserMail this class handles user mails.
replacePlaceholders($a_message, $a_user_id)
Mail Box class Base class for creating and handling mail boxes.
__substituteRecipients($a_rcp, $direction)
Note: This function can only be used, when ILIAS is configured to not use standards compliant mail ad...
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 All external mails are send to SOAP::sendMail starting a ki...
getUserIds($a_recipients)
get user_ids
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ doesRecipientStillExists()

ilMail::doesRecipientStillExists (   $a_recipient,
  $a_existing_recipients 
)

Definition at line 284 of file class.ilMail.php.

References explodeRecipients().

285  {
286  if(self::_usePearMail())
287  {
288  $recipients = $this->explodeRecipients($a_existing_recipients);
289  if(is_a($recipients, 'PEAR_Error'))
290  {
291  return false;
292  }
293  else
294  {
295  foreach($recipients as $rcp)
296  {
297  if (substr($rcp->mailbox, 0, 1) != '#')
298  {
299  if(trim($rcp->mailbox) == trim($a_recipient) ||
300  trim($rcp->mailbox.'@'.$rcp->host) == trim($a_recipient))
301  {
302  return true;
303  }
304  }
305  else if (substr($rcp->mailbox, 0, 7) == '#il_ml_')
306  {
307  if(trim($rcp->mailbox.'@'.$rcp->host) == trim($a_recipient))
308  {
309  return true;
310  }
311  }
312  else
313  {
314  if(trim($rcp->mailbox.'@'.$rcp->host) == trim($a_recipient))
315  {
316  return true;
317  }
318  }
319  }
320  }
321  }
322  else
323  {
324  $recipients = $this->explodeRecipients($a_existing_recipients);
325  if(count($recipients))
326  {
327  foreach($recipients as $recipient)
328  {
329  if(trim($recipient) == trim($a_recipient))
330  {
331  return true;
332  }
333  }
334  }
335  }
336 
337  return false;
338  }
explodeRecipients($a_recipients, $use_pear=true)
explode recipient string allowed seperators are &#39;,&#39; &#39;;&#39; &#39; &#39;
+ Here is the call graph for this function:

◆ enableSOAP()

ilMail::enableSOAP (   $a_status)

Definition at line 347 of file class.ilMail.php.

Referenced by ilMembershipCronNotifications\sendMail().

348  {
349  $this->soap_enabled = $a_status;
350  }
+ Here is the caller graph for this function:

◆ explodeRecipients()

ilMail::explodeRecipients (   $a_recipients,
  $use_pear = true 
)

explode recipient string allowed seperators are ',' ';' ' '

Returns an array with recipient objects

private

Returns
array with recipient objects. array[i]->mailbox gets the mailbox of the recipient. array[i]->host gets the host of the recipients. Returns a PEAR_Error object, if exploding failed. Use is_a() to test, if the return value is a PEAR_Error, then use $rcp->message to retrieve the error message.

Definition at line 2335 of file class.ilMail.php.

References $use_pear.

Referenced by __getCountRecipient(), __getEmailRecipients(), __substituteRecipients(), checkRecipients(), doesRecipientStillExists(), getEmailsOfRecipients(), getUserIds(), parseRcptOfMailingLists(), and validatePear().

2336  {
2337  $a_recipients = trim($a_recipients);
2338 
2339  // WHITESPACE IS NOT ALLOWED AS SEPERATOR
2340  #$a_recipients = preg_replace("/ /",",",$a_recipients);
2341  $a_recipients = preg_replace("/;/",",",$a_recipients);
2342 
2343  if (ilMail::_usePearMail() && $use_pear == true)
2344  {
2345  if (strlen(trim($a_recipients)) > 0)
2346  {
2347  require_once './Services/PEAR/lib/Mail/RFC822.php';
2348  $parser = new Mail_RFC822();
2349  return $parser->parseAddressList($a_recipients, "ilias", false, true);
2350  } else {
2351  return array();
2352  }
2353  }
2354  else
2355  {
2356  foreach(explode(',',$a_recipients) as $tmp_rec)
2357  {
2358  if($tmp_rec)
2359  {
2360  $rcps[] = trim($tmp_rec);
2361  }
2362  }
2363  return is_array($rcps) ? $rcps : array();
2364  }
2365  }
+ Here is the caller graph for this function:

◆ fetchMailData()

ilMail::fetchMailData (   $a_row)

fetch all query data from table mail public

Parameters
objectobject of query
Returns
array array of query data

Definition at line 877 of file class.ilMail.php.

Referenced by getMail(), getMailsOfFolder(), getNextMail(), getPreviousMail(), and getSavedData().

878  {
879  if (!$a_row) return;
880 
881  return array(
882  "mail_id" => $a_row->mail_id,
883  "user_id" => $a_row->user_id,
884  "folder_id" => $a_row->folder_id,
885  "sender_id" => $a_row->sender_id,
886  "attachments" => unserialize(stripslashes($a_row->attachments)),
887  "send_time" => $a_row->send_time,
888  "rcp_to" => $a_row->rcp_to,
889  "rcp_cc" => $a_row->rcp_cc,
890  "rcp_bcc" => $a_row->rcp_bcc,
891  "m_status" => $a_row->m_status,
892  "m_type" => unserialize(stripslashes($a_row->m_type)),
893  "m_email" => $a_row->m_email,
894  "m_subject" => $a_row->m_subject,
895  "m_message" => $a_row->m_message,
896  "import_name" => $a_row->import_name,
897  "use_placeholders"=> $a_row->use_placeholders);
898  }
+ Here is the caller graph for this function:

◆ formatNamesForOutput()

ilMail::formatNamesForOutput (   $users = '')

Prepends the fullname of each ILIAS login name (is user has a public profile) found in the passed string and brackets the ILIAS login name afterwards.

Parameters
string$usersString containing to, cc or bcc recipients
Returns
string Formatted names

public

Definition at line 465 of file class.ilMail.php.

References ilObjUser\_lookupId(), and ilObjUser\_lookupPref().

466  {
467  $users = trim($users);
468  if($users)
469  {
470  if(strstr($users, ','))
471  {
472  $rcp_to_array = array();
473 
474  $recipients = explode(',', $users);
475  foreach($recipients as $recipient)
476  {
477  $recipient = trim($recipient);
478  if($uid = ilObjUser::_lookupId($recipient))
479  {
480  if (in_array(ilObjUser::_lookupPref($uid, 'public_profile'), array("y", "g")))
481  {
482  $tmp_obj = self::getCachedUserInstance($uid);
483  $rcp_to_array[] = $tmp_obj->getFullname().' ['.$recipient.']';
484  }
485  else
486  {
487  $rcp_to_array[] = $recipient;
488  }
489  }
490  else
491  {
492  $rcp_to_array[] = $recipient;
493  }
494  }
495 
496  return trim(implode(', ', $rcp_to_array));
497  }
498  else
499  {
500  if($uid = ilObjUser::_lookupId($users))
501  {
502  if (in_array(ilObjUser::_lookupPref($uid, 'public_profile'), array("y", "g")))
503  {
504  $tmp_obj = self::getCachedUserInstance($uid);
505  return $tmp_obj->getFullname().' ['.$users.']';
506  }
507  else
508  {
509  return $users;
510  }
511  }
512  else
513  {
514  return $users;
515  }
516  }
517  }
518  else
519  {
520  return $this->lng->txt('not_available');
521  }
522  }
static _lookupId($a_user_str)
lookup id by login
_lookupPref($a_usr_id, $a_keyword)
+ Here is the call graph for this function:

◆ getAttachments()

ilMail::getAttachments ( )

get attachments public

Returns
array array of attachments

Definition at line 2317 of file class.ilMail.php.

2318  {
2319  return $this->mail_data["attachments"] ? $this->mail_data["attachments"] : array();
2320  }

◆ getCachedUserInstance()

static ilMail::getCachedUserInstance (   $a_usr_id)
staticprotected

Returns a cached instance of ilObjUser.

Parameters
integer$a_usr_id
Returns
ilObjUser

Definition at line 2798 of file class.ilMail.php.

2799  {
2800  if(isset(self::$userInstances[$a_usr_id]))
2801  {
2802  return self::$userInstances[$a_usr_id];
2803  }
2804 
2805  self::$userInstances[$a_usr_id] = new ilObjUser($a_usr_id);
2806  return self::$userInstances[$a_usr_id];
2807  }

◆ getEmailOfSender()

ilMail::getEmailOfSender ( )

get email of sender public

Returns
string email

Definition at line 2273 of file class.ilMail.php.

References ilUtil\is_email().

2274  {
2275  $umail = self::getCachedUserInstance($this->user_id);
2276  $sender = $umail->getEmail();
2277 
2278  if (ilUtil::is_email($sender))
2279  {
2280  return $sender;
2281  }
2282  else
2283  {
2284  return '';
2285  }
2286  }
static is_email($a_email)
This preg-based function checks whether an e-mail address is formally valid.
+ Here is the call graph for this function:

◆ getEmailsOfRecipients()

ilMail::getEmailsOfRecipients (   $a_rcp)

get email addresses of recipients public

Parameters
stringstring with login names or group names (start with #) or email address
Returns
string seperated by ','

Definition at line 1413 of file class.ilMail.php.

References $ref_id, $usr_id, ilObject\_getAllReferences(), ilObjGroup\_lookupIdByTitle(), explodeRecipients(), ilObjectFactory\getInstanceByRefId(), getUsePear(), ilObjUser\getUserIdByLogin(), and validatePear().

1414  {
1415  global $rbacreview;
1416 
1417  $addresses = array();
1418 
1419  $this->validatePear($a_rcp);
1420  if (ilMail::_usePearMail() && $this->getUsePear())
1421  {
1422  $tmp_rcp = $this->explodeRecipients($a_rcp);
1423  if (! is_a($tmp_rcp, 'PEAR_Error'))
1424  {
1425  foreach ($tmp_rcp as $rcp)
1426  {
1427  // NO GROUP
1428  if (substr($rcp->mailbox,0,1) != '#')
1429  {
1430  if (strtolower($rcp->host) != 'ilias')
1431  {
1432  $addresses[] = $rcp->mailbox.'@'.$rcp->host;
1433  continue;
1434  }
1435 
1436  if ($id = ilObjUser::getUserIdByLogin(addslashes($rcp->mailbox)))
1437  {
1438  $tmp_user = self::getCachedUserInstance($id);
1439  $addresses[] = $tmp_user->getEmail();
1440  continue;
1441  }
1442  }
1443  else
1444  {
1445  // Roles
1446  $role_ids = $rbacreview->searchRolesByMailboxAddressList($rcp->mailbox.'@'.$rcp->host);
1447  foreach($role_ids as $role_id)
1448  {
1449  foreach($rbacreview->assignedUsers($role_id) as $usr_id)
1450  {
1451  $tmp_user = self::getCachedUserInstance($usr_id);
1452  $addresses[] = $tmp_user->getEmail();
1453  }
1454  }
1455  }
1456  }
1457  }
1458  }
1459  else
1460  {
1461  $tmp_rcp = $this->explodeRecipients($a_rcp, $this->getUsePear());
1462 
1463  foreach ($tmp_rcp as $rcp)
1464  {
1465  // NO GROUP
1466  if (substr($rcp,0,1) != '#')
1467  {
1468  if (strpos($rcp,'@'))
1469  {
1470  $addresses[] = $rcp;
1471  continue;
1472  }
1473 
1474  if ($id = ilObjUser::getUserIdByLogin(addslashes($rcp)))
1475  {
1476  $tmp_user = self::getCachedUserInstance($id);
1477  $addresses[] = $tmp_user->getEmail();
1478  continue;
1479  }
1480  }
1481  else
1482  {
1483  // GROUP THINGS
1484  include_once("./Services/Object/classes/class.ilObjectFactory.php");
1485  include_once('./Modules/Group/classes/class.ilObjGroup.php');
1486 
1487  // Fix
1488  foreach(ilObjGroup::_getAllReferences(ilObjGroup::_lookupIdByTitle(addslashes(substr($rcp,1)))) as $ref_id)
1489  {
1490  $grp_object = ilObjectFactory::getInstanceByRefId($ref_id);
1491  break;
1492  }
1493  // GET EMAIL OF MEMBERS AND STORE THEM IN $addresses
1494  foreach ($grp_object->getGroupMemberIds() as $id)
1495  {
1496  $tmp_user = self::getCachedUserInstance($id);
1497  $addresses[] = $tmp_user->getEmail();
1498  }
1499  }
1500  }
1501  }
1502 
1503  return $addresses;
1504  }
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
explodeRecipients($a_recipients, $use_pear=true)
explode recipient string allowed seperators are &#39;,&#39; &#39;;&#39; &#39; &#39;
validatePear($a_recipients)
static _getAllReferences($a_id)
get all reference ids of object
getUserIdByLogin($a_login)
_lookupIdByTitle($a_title)
$ref_id
Definition: sahs_server.php:39
+ Here is the call graph for this function:

◆ getIliasMailerAddress()

static ilMail::getIliasMailerAddress ( )
static

Builds an email address used for system notifications.

public

Returns
string

Definition at line 2145 of file class.ilMail.php.

References $ilSetting, ilMimeMail\_mimeEncode(), and ilUtil\is_email().

Referenced by ilMailSummaryNotification\send().

2146  {
2147  global $ilSetting;
2148 
2149  include_once 'Services/Mail/classes/class.ilMimeMail.php';
2150 
2151  $no_reply_adress = trim($ilSetting->get('mail_external_sender_noreply'));
2152  if(strlen($no_reply_adress))
2153  {
2154  if(strpos($no_reply_adress, '@') === false)
2155  $no_reply_adress = 'noreply@'.$no_reply_adress;
2156 
2157  if(!ilUtil::is_email($no_reply_adress))
2158  {
2159  $no_reply_adress = 'noreply@'.$_SERVER['SERVER_NAME'];
2160  }
2161 
2162  $sender = ilMimeMail::_mimeEncode(self::_getIliasMailerName()).
2163  ' <'.$no_reply_adress.'>';
2164  }
2165  else
2166  {
2167  $sender = ilMimeMail::_mimeEncode(self::_getIliasMailerName()).
2168  ' <noreply@'.$_SERVER['SERVER_NAME'].'>';
2169  }
2170 
2171  return $sender;
2172  }
static is_email($a_email)
This preg-based function checks whether an e-mail address is formally valid.
_mimeEncode($a_string)
global $ilSetting
Definition: privfeed.php:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMail()

ilMail::getMail (   $a_mail_id)

get data of one mail public

Parameters
intmail_id
Returns
array mail_data

Definition at line 690 of file class.ilMail.php.

References $mail_data, $res, DB_FETCHMODE_OBJECT, and fetchMailData().

691  {
692  global $ilDB;
693 
694  $res = $ilDB->queryf("
695  SELECT * FROM ". $this->table_mail ."
696  WHERE user_id = %s
697  AND mail_id = %s",
698  array('integer', 'integer'),
699  array($this->user_id, $a_mail_id));
700 
701  $this->mail_data =$this->fetchMailData($res->fetchRow(DB_FETCHMODE_OBJECT));
702 
703  return $this->mail_data;
704  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
fetchMailData($a_row)
fetch all query data from table mail public
+ Here is the call graph for this function:

◆ getMailCounterData()

ilMail::getMailCounterData ( )

get mail counter data returns data array with indexes "total","read","unread" public

Returns
array mail_counter data

Definition at line 676 of file class.ilMail.php.

677  {
678  return is_array($this->mail_counter) ? $this->mail_counter : array(
679  "total" => 0,
680  "read" => 0,
681  "unread" => 0);
682  }

◆ getMailObjectReferenceId()

ilMail::getMailObjectReferenceId ( )

Definition at line 450 of file class.ilMail.php.

References $mail_obj_ref_id.

451  {
452  return $this->mail_obj_ref_id;
453  }

◆ getMailsOfFolder()

ilMail::getMailsOfFolder (   $a_folder_id,
  $filter = array() 
)

get all mails of a specific folder public

Parameters
integerid of folder
arrayoptional filter array
Returns
array mails

Definition at line 569 of file class.ilMail.php.

References $query, $res, $row, and fetchMailData().

Referenced by deleteMailsOfFolder(), and ilPDMailBlockGUI\getMails().

570  {
571  global $ilDB;
572 
573  $this->mail_counter = array();
574  $this->mail_counter['read'] = 0;
575  $this->mail_counter['unread'] = 0;
576 
577  $query = "SELECT sender_id, m_subject, mail_id, m_status, send_time FROM ". $this->table_mail ."
578  LEFT JOIN object_data ON obj_id = sender_id
579  WHERE user_id = %s
580  AND folder_id = %s
581  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)) ";
582 
583  if($filter['status'])
584  {
585  $query .= ' AND m_status = '.$ilDB->quote($filter['status'], 'text');
586  }
587  if($filter['type'])
588  {
589  $query .= ' AND '.$ilDB->like('m_type', 'text', '%%:"'.$filter['type'].'"%%', false);
590  }
591 
592  $query .= " ORDER BY send_time DESC";
593 
594  $res = $ilDB->queryf($query,
595  array('integer', 'integer'),
596  array($this->user_id, $a_folder_id));
597 
598  while ($row = $ilDB->fetchObject($res))
599  {
600  $tmp = $this->fetchMailData($row);
601 
602  if($tmp['m_status'] == 'read')
603  {
604  ++$this->mail_counter['read'];
605  }
606 
607  if($tmp['m_status'] == 'unread')
608  {
609  ++$this->mail_counter['unread'];
610  }
611 
612  $output[] = $tmp;
613  }
614 
615  $this->mail_counter['total'] = count($output);
616 
617  return $output ? $output : array();
618  }
fetchMailData($a_row)
fetch all query data from table mail public
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNextMail()

ilMail::getNextMail (   $a_mail_id)

Definition at line 543 of file class.ilMail.php.

References $mail_data, $res, DB_FETCHMODE_OBJECT, and fetchMailData().

544  {
545  global $ilDB;
546 
547  $ilDB->setLimit(1);
548  $res = $ilDB->queryf("
549  SELECT b.* FROM " . $this->table_mail ." a
550  INNER JOIN ".$this->table_mail ." b ON b.folder_id = a.folder_id
551  AND b.user_id = a.user_id AND b.send_time < a.send_time
552  WHERE a.user_id = %s
553  AND a.mail_id = %s ORDER BY b.send_time DESC",
554  array('integer', 'integer'),
555  array($this->user_id, $a_mail_id));
556 
557  $this->mail_data = $this->fetchMailData($res->fetchRow(DB_FETCHMODE_OBJECT));
558 
559  return $this->mail_data;
560  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
fetchMailData($a_row)
fetch all query data from table mail public
+ Here is the call graph for this function:

◆ getPreviousMail()

ilMail::getPreviousMail (   $a_mail_id)

Definition at line 524 of file class.ilMail.php.

References $mail_data, $res, DB_FETCHMODE_OBJECT, and fetchMailData().

525  {
526  global $ilDB;
527 
528  $ilDB->setLimit(1);
529  $res = $ilDB->queryf("
530  SELECT b.* FROM " . $this->table_mail ." a
531  INNER JOIN ".$this->table_mail ." b ON b.folder_id = a.folder_id
532  AND b.user_id = a.user_id AND b.send_time > a.send_time
533  WHERE a.user_id = %s
534  AND a.mail_id = %s ORDER BY b.send_time ASC",
535  array('integer', 'integer'),
536  array($this->user_id, $a_mail_id));
537 
538  $this->mail_data = $this->fetchMailData($res->fetchRow(DB_FETCHMODE_OBJECT));
539 
540  return $this->mail_data;
541  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
fetchMailData($a_row)
fetch all query data from table mail public
+ Here is the call graph for this function:

◆ getSalutation()

static ilMail::getSalutation (   $a_usr_id,
  $a_language = null 
)
static

Get salutation.

Parameters
int$a_usr_id
Returns

Definition at line 2736 of file class.ilMail.php.

References $lang, $lng, ilObjUser\_lookupGender(), and ilObjUser\_lookupName().

Referenced by ilForum\__formatMessage(), ilTestManScoringParticipantNotification\buildBody(), ilSystemNotification\compose(), ilForum\formatNotification(), ilForum\formatPostActivationNotification(), ilPaymentNotification\send(), ilMailSummaryNotification\send(), ilRegistrationMailNotification\send(), ilGroupMembershipMailNotification\send(), ilCourseMembershipMailNotification\send(), ilDiskQuotaSummaryNotification\send(), ilExerciseMailNotification\send(), ilCalendarMailNotification\send(), ilTestMailNotification\sendAdvancedNotification(), and ilTestMailNotification\sendSimpleNotification().

2737  {
2738  global $lng;
2739 
2740  $lang = $a_language ? $a_language : $lng;
2741 
2742  $lang->loadLanguageModule('mail');
2743  $gender = ilObjUser::_lookupGender($a_usr_id);
2744  $gender = $gender ? $gender : 'n';
2745  $name = ilObjUser::_lookupName($a_usr_id);
2746 
2747  if(!strlen($name['firstname']))
2748  {
2749  return $lang->txt('mail_salutation_anonymous').',';
2750  }
2751 
2752  return $lang->txt('mail_salutation_'.$gender).' '.
2753  ($name['title'] ? $name['title'].' ' : '').
2754  ($name['firstname'] ? $name['firstname'].' ' : '').
2755  $name['lastname'].',';
2756  }
static _lookupName($a_user_id)
lookup user name
static _lookupGender($a_user_id)
Lookup gender.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSavedData()

ilMail::getSavedData ( )

get saved data public

Returns
array of saved data

Definition at line 1729 of file class.ilMail.php.

References $mail_data, $res, DB_FETCHMODE_OBJECT, and fetchMailData().

Referenced by ilObjUserFolderGUI\mailObject(), and savePostData().

1730  {
1731  global $ilDB;
1732 
1733  $res = $ilDB->queryf('
1734  SELECT * FROM '. $this->table_mail_saved .'
1735  WHERE user_id = %s',
1736  array('integer'),
1737  array($this->user_id));
1738 
1739  $this->mail_data = $this->fetchMailData($res->fetchRow(DB_FETCHMODE_OBJECT));
1740 
1741  return $this->mail_data;
1742  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
fetchMailData($a_row)
fetch all query data from table mail public
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSaveInSentbox()

ilMail::getSaveInSentbox ( )

Definition at line 375 of file class.ilMail.php.

References $save_in_sentbox.

Referenced by sendMail().

376  {
377  return $this->save_in_sentbox;
378  }
+ Here is the caller graph for this function:

◆ getSubjectPrefix()

static ilMail::getSubjectPrefix ( )
static

Get text that will be prepended to auto generated mails.

Returns
string subject prefix

Definition at line 2723 of file class.ilMail.php.

References $ilSetting.

Referenced by ilMimeMail\Subject().

2724  {
2725  global $ilSetting;
2726  static $prefix = null;
2727 
2728  return $prefix == null ? $ilSetting->get('mail_subject_prefix','') : $prefix;
2729  }
global $ilSetting
Definition: privfeed.php:40
+ Here is the caller graph for this function:

◆ getUsePear()

ilMail::getUsePear ( )
private

Definition at line 2763 of file class.ilMail.php.

References $use_pear.

Referenced by __getCountRecipient(), checkRecipients(), getEmailsOfRecipients(), and getUserIds().

2764  {
2765  return $this->use_pear;
2766  }
+ Here is the caller graph for this function:

◆ getUserIds()

ilMail::getUserIds (   $a_recipients)

get user_ids

Parameters
stringrecipients seperated by ','
Returns
string error message

Definition at line 1273 of file class.ilMail.php.

References $log, $ref_id, $usr_id, ilObject\_getAllReferences(), ilObjUser\_lookupId(), ilObjGroup\_lookupIdByTitle(), explodeRecipients(), ilObjectFactory\getInstanceByRefId(), getUsePear(), ilObjUser\getUserIdByLogin(), ilUtil\groupNameExists(), and validatePear().

Referenced by distributeMail().

1274  {
1275  global $log, $rbacreview;
1276  $ids = array();
1277 
1278  $this->validatePear($a_recipients);
1279  if (ilMail::_usePearMail() && $this->getUsePear() == true)
1280  {
1281  $tmp_names = $this->explodeRecipients($a_recipients );
1282  if (! is_a($tmp_names, 'PEAR_Error'))
1283  {
1284  for ($i = 0;$i < count($tmp_names); $i++)
1285  {
1286  if ( substr($tmp_names[$i]->mailbox,0,1) === '#' ||
1287  (substr($tmp_names[$i]->mailbox,0,1) === '"' &&
1288  substr($tmp_names[$i]->mailbox,1,1) === '#' ) )
1289  {
1290  $role_ids = $rbacreview->searchRolesByMailboxAddressList($tmp_names[$i]->mailbox.'@'.$tmp_names[$i]->host);
1291  foreach($role_ids as $role_id)
1292  {
1293  foreach($rbacreview->assignedUsers($role_id) as $usr_id)
1294  {
1295  $ids[] = $usr_id;
1296  }
1297  }
1298  }
1299  else if (strtolower($tmp_names[$i]->host) == 'ilias')
1300  {
1301  if ($id = ilObjUser::getUserIdByLogin(addslashes($tmp_names[$i]->mailbox)))
1302  {
1303  //$log->write('class.ilMail->getUserIds() recipient:'.$tmp_names[$i]->mailbox.'@'.$tmp_names[$i]->host.' user_id:'.$id);
1304  $ids[] = $id;
1305  }
1306  else
1307  {
1308  //$log->write('class.ilMail->getUserIds() no user account found for recipient:'.$tmp_names[$i]->mailbox.'@'.$tmp_names[$i]->host);
1309  }
1310  }
1311  else
1312  {
1313  // Fixed mantis bug #5875
1314  if($id = ilObjUser::_lookupId($tmp_names[$i]->mailbox.'@'.$tmp_names[$i]->host))
1315  {
1316  $ids[] = $id;
1317  }
1318  else
1319  {
1320  //$log->write('class.ilMail->getUserIds() external recipient:'.$tmp_names[$i]->mailbox.'@'.$tmp_names[$i]->host);
1321  }
1322  }
1323  }
1324  }
1325  else
1326  {
1327  //$log->write('class.ilMail->getUserIds() illegal recipients:'.$a_recipients);
1328  }
1329  }
1330  else
1331  {
1332  $tmp_names = $this->explodeRecipients($a_recipients, $this->getUsePear());
1333  for ($i = 0;$i < count($tmp_names); $i++)
1334  {
1335  if (substr($tmp_names[$i],0,1) == '#')
1336  {
1337  if(ilUtil::groupNameExists(addslashes(substr($tmp_names[$i],1))))
1338  {
1339  include_once("./Services/Object/classes/class.ilObjectFactory.php");
1340  include_once('./Modules/Group/classes/class.ilObjGroup.php');
1341 
1342  foreach(ilObject::_getAllReferences(ilObjGroup::_lookupIdByTitle(addslashes(substr($tmp_names[$i],1)))) as $ref_id)
1343  {
1344  $grp_object = ilObjectFactory::getInstanceByRefId($ref_id);
1345  break;
1346  }
1347  // STORE MEMBER IDS IN $ids
1348  foreach ($grp_object->getGroupMemberIds() as $id)
1349  {
1350  $ids[] = $id;
1351  }
1352  }
1353  // is role: get role ids
1354  elseif($role_id = $rbacreview->roleExists(addslashes(substr($tmp_names[$i],1))))
1355  {
1356  foreach($rbacreview->assignedUsers($role_id) as $usr_id)
1357  {
1358  $ids[] = $usr_id;
1359  }
1360  }
1361 
1362  }
1363  else if (!empty($tmp_names[$i]))
1364  {
1365  if ($id = ilObjUser::getUserIdByLogin(addslashes($tmp_names[$i])))
1366  {
1367  $ids[] = $id;
1368  }
1369  }
1370  }
1371  }
1372  return array_unique($ids);
1373  }
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static groupNameExists($a_group_name, $a_id=0)
checks if group name already exists.
static _lookupId($a_user_str)
lookup id by login
explodeRecipients($a_recipients, $use_pear=true)
explode recipient string allowed seperators are &#39;,&#39; &#39;;&#39; &#39; &#39;
validatePear($a_recipients)
static _getAllReferences($a_id)
get all reference ids of object
getUserIdByLogin($a_login)
_lookupIdByTitle($a_title)
$ref_id
Definition: sahs_server.php:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isSOAPEnabled()

ilMail::isSOAPEnabled ( )

Definition at line 351 of file class.ilMail.php.

References $ilSetting, $soap_enabled, ilContext\CONTEXT_CRON, and ilContext\getType().

Referenced by sendMimeMail().

352  {
353  global $ilSetting;
354 
355  if(!extension_loaded('curl') || !$ilSetting->get('soap_user_administration'))
356  {
357  return false;
358  }
359 
360  // Prevent using SOAP in cron context
362  {
363  return false;
364  }
365 
366  return (bool) $this->soap_enabled;
367  }
const CONTEXT_CRON
global $ilSetting
Definition: privfeed.php:40
static getType()
Get context type.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ markRead()

ilMail::markRead (   $a_mail_ids)

mark mails as read public

Parameters
arraymail ids
Returns
bool

Definition at line 712 of file class.ilMail.php.

References $data, $in, $query, and $res.

713  {
714 
715  global $ilDB;
716 
717  $data = array();
718  $data_types = array();
719 
720  $query = "UPDATE ". $this->table_mail ."
721  SET m_status = %s
722  WHERE user_id = %s ";
723  array_push($data_types, 'text', 'integer');
724  array_push($data, 'read', $this->user_id);
725 
726  $cnt_mail_ids = count($a_mail_ids);
727 
728  if (is_array($a_mail_ids) &&
729  count($a_mail_ids) > 0)
730  {
731 
732  $in = 'mail_id IN (';
733  $counter = 0;
734  foreach($a_mail_ids as $a_mail_id)
735  {
736  array_push($data, $a_mail_id);
737  array_push($data_types, 'integer');
738 
739  if($counter > 0) $in .= ',';
740  $in .= '%s';
741  ++$counter;
742  }
743  $in .= ')';
744 
745  $query .= ' AND '.$in;
746  }
747 
748  $res = $ilDB->manipulateF($query, $data_types, $data);
749 
750  return true;
751  }
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data

◆ markUnread()

ilMail::markUnread (   $a_mail_ids)

mark mails as unread public

Parameters
arraymail ids
Returns
bool

Definition at line 759 of file class.ilMail.php.

References $data, $in, and $query.

760  {
761  global $ilDB;
762 
763  $data = array();
764  $data_types = array();
765 
766  $query = "UPDATE ". $this->table_mail ."
767  SET m_status = %s
768  WHERE user_id = %s ";
769  array_push($data_types, 'text', 'integer');
770  array_push($data, 'unread', $this->user_id);
771 
772  $cnt_mail_ids = count($a_mail_ids);
773 
774  if (is_array($a_mail_ids) &&
775  count($a_mail_ids) > 0)
776  {
777 
778  $in = 'mail_id IN (';
779  $counter = 0;
780  foreach($a_mail_ids as $a_mail_id)
781  {
782  array_push($data, $a_mail_id);
783  array_push($data_types, 'integer');
784 
785  if($counter > 0) $in .= ',';
786  $in .= '%s';
787  ++$counter;
788  }
789  $in .= ')';
790 
791  $query .= ' AND '.$in;
792  }
793 
794  $statement = $ilDB->manipulateF($query, $data_types, $data);
795 
796  return true;
797  }
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data

◆ moveMailsToFolder()

ilMail::moveMailsToFolder (   $a_mail_ids,
  $a_folder_id 
)

move mail to folder public

Parameters
arraymail ids
intfolder_id
Returns
bool

Definition at line 806 of file class.ilMail.php.

References $data, $in, and $query.

807  {
808  global $ilDB;
809 
810  $data = array();
811  $data_types = array();
812 
813  $query = "UPDATE ". $this->table_mail ."
814  SET folder_id = %s
815  WHERE user_id = %s ";
816  array_push($data_types, 'text', 'integer');
817  array_push($data, $a_folder_id, $this->user_id);
818 
819  $cnt_mail_ids = count($a_mail_ids);
820 
821  if (is_array($a_mail_ids) &&
822  count($a_mail_ids) > 0)
823  {
824 
825  $in = 'mail_id IN (';
826  $counter = 0;
827  foreach($a_mail_ids as $a_mail_id)
828  {
829  array_push($data, $a_mail_id);
830  array_push($data_types, 'integer');
831 
832  if($counter > 0) $in .= ',';
833  $in .= '%s';
834  ++$counter;
835  }
836  $in .= ')';
837 
838  $query .= ' AND '.$in;
839  }
840 
841  $statement = $ilDB->manipulateF($query, $data_types, $data);
842 
843  return true;
844  }
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data

◆ parseRcptOfMailingLists()

ilMail::parseRcptOfMailingLists (   $rcpt = '',
  $maintain_lists = false 
)

Definition at line 1958 of file class.ilMail.php.

References explodeRecipients().

Referenced by sendMail().

1959  {
1960  if ($rcpt == '')
1961  {
1962  if(!$maintain_lists)
1963  {
1964  return $rcpt;
1965  }
1966  else
1967  {
1968  return array();
1969  }
1970  }
1971 //@todo check rcp pear validation
1972  $arrRcpt = $this->explodeRecipients(trim($rcpt));
1973  if (!is_array($arrRcpt) || empty($arrRcpt))
1974  {
1975  if(!$maintain_lists)
1976  {
1977  return $rcpt;
1978  }
1979  else
1980  {
1981  return array();
1982  }
1983  }
1984 
1985  $new_rcpt = array();
1986 
1987  foreach ($arrRcpt as $item)
1988  {
1989  if (ilMail::_usePearMail())
1990  {
1991  if (substr($item->mailbox, 0, 7) == '#il_ml_')
1992  {
1993  if ($this->mlists->mailingListExists($item->mailbox))
1994  {
1995  foreach ($this->mlists->getCurrentMailingList()->getAssignedEntries() as $entry)
1996  {
1997  if(!$maintain_lists)
1998  {
1999  $new_rcpt[] = ($entry['login'] != '' ? $entry['login'] : $entry['email']);
2000  }
2001  else
2002  {
2003  $new_rcpt[$item->mailbox][] = ($entry['login'] != '' ? $entry['login'] : $entry['email']);
2004  }
2005  }
2006  }
2007  }
2008  else
2009  {
2010  if(!$maintain_lists)
2011  {
2012  $new_rcpt[] = $item->mailbox.'@'.$item->host;
2013  }
2014  else
2015  {
2016  $new_rcpt[0][] = $item->mailbox.'@'.$item->host;
2017  }
2018  }
2019  }
2020  else
2021  {
2022  if (substr($item, 0, 7) == '#il_ml_')
2023  {
2024  if ($this->mlists->mailingListExists($item))
2025  {
2026  foreach ($this->mlists->getCurrentMailingList()->getAssignedEntries() as $entry)
2027  {
2028  if(!$maintain_lists)
2029  {
2030  $new_rcpt[] = ($entry['login'] != '' ? $entry['login'] : $entry['email']);
2031  }
2032  else
2033  {
2034  $new_rcpt[$item][] = ($entry['login'] != '' ? $entry['login'] : $entry['email']);
2035  }
2036  }
2037  }
2038  }
2039  else
2040  {
2041  if(!$maintain_lists)
2042  {
2043  $new_rcpt[] = $item;
2044  }
2045  else
2046  {
2047  $new_rcpt[0][] = $item;
2048  }
2049  }
2050  }
2051  }
2052 
2053  if(!$maintain_lists)
2054  {
2055  return implode(',', $new_rcpt);
2056  }
2057  else
2058  {
2059  return $new_rcpt;
2060  }
2061  }
explodeRecipients($a_recipients, $use_pear=true)
explode recipient string allowed seperators are &#39;,&#39; &#39;;&#39; &#39; &#39;
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readMailObjectReferenceId()

ilMail::readMailObjectReferenceId ( )

read and set mail object id private

Definition at line 444 of file class.ilMail.php.

References ilMailGlobalServices\getMailObjectRefId().

Referenced by __construct().

445  {
446  include_once 'Services/Mail/classes/class.ilMailGlobalServices.php';
447  $this->mail_obj_ref_id = ilMailGlobalServices::getMailObjectRefId();
448  }
static getMailObjectRefId()
Determines the reference id of the mail object and stores this information in a local cache variable...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ replacePlaceholders()

ilMail::replacePlaceholders (   $a_message,
  $a_user_id 
)

Definition at line 1018 of file class.ilMail.php.

References $lng.

Referenced by distributeMail(), and sendInternalMail().

1019  {
1020  global $lng;
1021 
1022  $user = self::getCachedUserInstance($a_user_id);
1023 
1024  // determine salutation
1025  switch ($user->getGender())
1026  {
1027  case 'f': $gender_salut = $lng->txt('salutation_f');
1028  break;
1029  case 'm': $gender_salut = $lng->txt('salutation_m');
1030  break;
1031  }
1032 
1033  $a_message = str_replace('[MAIL_SALUTATION]', $gender_salut, $a_message);
1034  $a_message = str_replace('[LOGIN]', $user->getLogin(), $a_message);
1035  $a_message = str_replace('[FIRST_NAME]', $user->getFirstname(), $a_message);
1036  $a_message = str_replace('[LAST_NAME]', $user->getLastname(), $a_message);
1037  $a_message = str_replace('[ILIAS_URL]', ILIAS_HTTP_PATH.'/login.php?client_id='.CLIENT_ID, $a_message);
1038  $a_message = str_replace('[CLIENT_NAME]', CLIENT_NAME, $a_message);
1039 
1040  return $a_message;
1041  }
+ Here is the caller graph for this function:

◆ saveAttachments()

ilMail::saveAttachments (   $a_attachments)

set attachments

Parameters
arrayarray of attachments public
Returns
bool

Definition at line 2294 of file class.ilMail.php.

2295  {
2296  global $ilDB;
2297 
2298  $ilDB->update($this->table_mail_saved,
2299  array
2300  (
2301  'attachments' => array('clob', serialize($a_attachments))
2302  ),
2303  array
2304  (
2305  'user_id' => array('integer', $this->user_id)
2306  )
2307  );
2308 
2309  return true;
2310  }

◆ saveInSentbox()

ilMail::saveInSentbox (   $a_attachment,
  $a_rcp_to,
  $a_rcp_cc,
  $a_rcp_bcc,
  $a_type,
  $a_m_subject,
  $a_m_message 
)

send mime mail using class.ilMimeMail.php

Parameters
arrayattachments
stringto
stringcc
stringbcc
stringtype
stringsubject
stringmessage public
Returns
int mail id
Todo:
: mjansen 23.12.2011 Why is $a_as_email undefined here?

Definition at line 2075 of file class.ilMail.php.

References sendInternalMail().

Referenced by sendMail().

2077  {
2078  include_once "Services/Mail/classes/class.ilMailbox.php";
2079 
2080  $mbox = new ilMailbox($this->user_id);
2081  $sent_id = $mbox->getSentFolder();
2082 
2084  return $this->sendInternalMail($sent_id,$this->user_id,$a_attachment,$a_rcp_to,$a_rcp_cc,
2085  $a_rcp_bcc,'read',$a_type,$a_as_email,$a_m_subject,$a_m_message,$this->user_id, 0);
2086  }
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)
save mail in folder private
Mail Box class Base class for creating and handling mail boxes.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ savePostData()

ilMail::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 
)

save post data in table public

Parameters
intuser_id
arrayattachments
stringto
stringcc
stringbcc
arraytype of mail (system,normal,email)
intas email (1,0)
stringsubject
stringmessage
intuse placeholders
Returns
bool

Definition at line 1677 of file class.ilMail.php.

References getSavedData().

Referenced by ilObjUserFolderGUI\mailObject().

1687  {
1688  global $ilDB;
1689 
1690 
1691  if(!$a_attachments) $a_attachments = NULL;
1692  if(!$a_rcp_to) $a_rcp_to = NULL;
1693  if(!$a_rcp_cc) $a_rcp_cc = NULL;
1694  if(!$a_rcp_bcc) $a_rcp_bcc = NULL;
1695  if(!$a_m_type) $a_m_type = NULL;
1696  if(!$a_m_email) $a_m_email = NULL;
1697  if(!$a_m_message) $a_m_message = NULL;
1698  if(!$a_use_placeholders) $a_use_placeholders = '0';
1699 
1700 
1701  $statement = $ilDB->manipulateF('
1702  DELETE FROM '. $this->table_mail_saved .'
1703  WHERE user_id = %s',
1704  array('integer'), array($this->user_id));
1705 
1706  $ilDB->insert($this->table_mail_saved, array(
1707  'user_id' => array('integer', $a_user_id),
1708  'attachments' => array('clob', serialize($a_attachments)),
1709  'rcp_to' => array('clob', $a_rcp_to),
1710  'rcp_cc' => array('clob', $a_rcp_cc),
1711  'rcp_bcc' => array('clob', $a_rcp_bcc),
1712  'm_type' => array('text', serialize($a_m_type)),
1713  'm_email' => array('integer', $a_m_email),
1714  'm_subject' => array('text', $a_m_subject),
1715  'm_message' => array('clob', $a_m_message),
1716  'use_placeholders' => array('integer', $a_use_placeholders),
1717  ));
1718 
1719  $this->getSavedData();
1720 
1721  return true;
1722  }
getSavedData()
get saved data public
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendInternalMail()

ilMail::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 
)

save mail in folder private

Parameters
integerid of folder
integersender_id
arrayattachments
stringto
stringcc
stringbcc
stringstatus
stringtype of mail (system,normal)
integeras email (1,0)
stringsubject
stringmessage
integeruser_id
Returns
integer mail_id

Definition at line 953 of file class.ilMail.php.

References $log, $user_id, and replacePlaceholders().

Referenced by distributeMail(), and saveInSentbox().

965  {
966  $a_user_id = $a_user_id ? $a_user_id : $this->user_id;
967 
968  global $ilDB, $log;
969  //$log->write('class.ilMail->sendInternalMail to user_id:'.$a_rcp_to.' '.$a_m_message);
970 
971  if ($a_use_placeholders)
972  {
973  $a_m_message = $this->replacePlaceholders($a_m_message, $a_user_id);
974  }
975  else
976  {
977  $a_use_placeholders = '0';
978  }
979 
980 
981  if(!$a_user_id) $a_user_id = '0';
982  if(!$a_folder_id) $a_folder_id = '0';
983  if(!$a_sender_id) $a_sender_id = NULL;
984  if(!$a_attachments) $a_attachments = NULL;
985  if(!$a_rcp_to) $a_rcp_to = NULL;
986  if(!$a_rcp_cc) $a_rcp_cc = NULL;
987  if(!$a_rcp_bcc) $a_rcp_bcc = NULL;
988  if(!$a_status) $a_status = NULL;
989  if(!$a_m_type) $a_m_type = NULL;
990  if(!$a_m_email) $a_m_email = NULL;
991  if(!$a_m_subject) $a_m_subject = NULL;
992  if(!$a_m_message) $a_m_message = NULL;
993 
994 
995  $next_id = $ilDB->nextId($this->table_mail);
996 
997  $ilDB->insert($this->table_mail, array(
998  'mail_id' => array('integer', $next_id),
999  'user_id' => array('integer', $a_user_id),
1000  'folder_id' => array('integer', $a_folder_id),
1001  'sender_id' => array('integer', $a_sender_id),
1002  'attachments' => array('clob', serialize($a_attachments)),
1003  'send_time' => array('timestamp', date('Y-m-d H:i:s', time())),
1004  'rcp_to' => array('clob', $a_rcp_to),
1005  'rcp_cc' => array('clob', $a_rcp_cc),
1006  'rcp_bcc' => array('clob', $a_rcp_bcc),
1007  'm_status' => array('text', $a_status),
1008  'm_type' => array('text', serialize($a_m_type)),
1009  'm_email' => array('integer', $a_m_email),
1010  'm_subject' => array('text', $a_m_subject),
1011  'm_message' => array('clob', $a_m_message)
1012  ));
1013 
1014  return $next_id; //$ilDB->getLastInsertId();
1015 
1016  }
replacePlaceholders($a_message, $a_user_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendMail()

ilMail::sendMail (   $a_rcp_to,
  $a_rcp_cc,
  $a_rcp_bc,
  $a_m_subject,
  $a_m_message,
  $a_attachment,
  $a_type,
  $a_use_placeholders = 0 
)

send external mail using class.ilMimeMail.php

Parameters
stringto
stringcc
stringbcc
stringsubject
stringmessage
arrayattachments
arraytype (normal and/or system and/or email)
integeralso as email (0,1) public
Returns
array of saved data

Definition at line 1757 of file class.ilMail.php.

References $lng, $log, __checkSystemRecipients(), __getCountRecipients(), __getEmailRecipients(), __substituteRecipients(), appendInstallationSignature(), checkMail(), checkRecipients(), deleteMails(), distributeMail(), getSaveInSentbox(), ilMailingList\MODE_TEMPORARY, parseRcptOfMailingLists(), saveInSentbox(), and sendMimeMail().

1758  {
1759  global $lng,$rbacsystem,$log;
1760  //$log->write('class.ilMail.sendMail '.$a_rcp_to.' '.$a_m_subject);
1761 
1762  $this->mail_to_global_roles = true;
1763  if($this->user_id != ANONYMOUS_USER_ID)
1764  {
1765  $this->mail_to_global_roles = $rbacsystem->checkAccessOfUser($this->user_id, 'mail_to_global_roles', $this->mail_obj_ref_id);
1766  }
1767 
1768  $error_message = '';
1769  $message = '';
1770 
1771  if (in_array("system",$a_type))
1772  {
1773  $this->__checkSystemRecipients($a_rcp_to);
1774  $a_type = array('system');
1775  }
1776 
1777  if ($a_attachment)
1778  {
1779  if (!$this->mfile->checkFilesExist($a_attachment))
1780  {
1781  return "YOUR LIST OF ATTACHMENTS IS NOT VALID, PLEASE EDIT THE LIST";
1782  }
1783  }
1784  // CHECK NECESSARY MAIL DATA FOR ALL TYPES
1785  if ($error_message = $this->checkMail($a_rcp_to,$a_rcp_cc,$a_rcp_bc,$a_m_subject,$a_m_message,$a_type))
1786  {
1787  return $error_message;
1788  }
1789 
1790  try
1791  {
1792  // check recipients
1793  if ($error_message = $this->checkRecipients($a_rcp_to,$a_type))
1794  {
1795  $message .= $error_message;
1796  }
1797 
1798  if ($error_message = $this->checkRecipients($a_rcp_cc,$a_type))
1799  {
1800  $message .= $error_message;
1801  }
1802 
1803  if ($error_message = $this->checkRecipients($a_rcp_bc,$a_type))
1804  {
1805  $message .= $error_message;
1806  }
1807  }
1808 
1809  catch(ilMailException $e)
1810  {
1811  return $this->lng->txt($e->getMessage());
1812  }
1813 
1814  // if there was an error
1815  if (!empty($message))
1816  {
1817  return $this->lng->txt("mail_following_rcp_not_valid").$message;
1818  }
1819 
1820  // ACTIONS FOR ALL TYPES
1821 
1822 
1823  // GET RCPT OF MAILING LISTS
1824 
1825  $rcp_to_list = $this->parseRcptOfMailingLists($a_rcp_to, true);
1826  $rcp_cc_list = $this->parseRcptOfMailingLists($a_rcp_cc, true);
1827  $rcp_bc_list = $this->parseRcptOfMailingLists($a_rcp_bc, true);
1828 
1829  $rcp_to = $rcp_cc = $rcp_bc = array();
1830  foreach($rcp_to_list as $mlist_id => $mlist_rec)
1831  {
1832  if($mlist_id)
1833  {
1834  // internal mailing lists are sent as bcc
1835  $mlist_id = substr($mlist_id, 7);
1836  if($this->mlists->get($mlist_id)->getMode() == ilMailingList::MODE_TEMPORARY)
1837  {
1838  $rcp_bc = array_merge($rcp_bc, $mlist_rec);
1839  continue;
1840  }
1841  }
1842 
1843  $rcp_to = array_merge($rcp_to, $mlist_rec);
1844  }
1845  foreach($rcp_cc_list as $mlist_id => $mlist_rec)
1846  {
1847  if($mlist_id)
1848  {
1849  // internal mailing lists are sent as bcc
1850  $mlist_id = substr($mlist_id, 7);
1851  if($this->mlists->get($mlist_id)->getMode() == ilMailingList::MODE_TEMPORARY)
1852  {
1853  $rcp_bc = array_merge($rcp_bc, $mlist_rec);
1854  continue;
1855  }
1856  }
1857 
1858  $rcp_cc = array_merge($rcp_cc, $mlist_rec);
1859  }
1860  foreach($rcp_bc_list as $mlist_id => $mlist_rec)
1861  {
1862  $rcp_bc = array_merge($rcp_bc, $mlist_rec);
1863  }
1864 
1865  $rcp_to = implode(',', $rcp_to);
1866  $rcp_cc = implode(',', $rcp_cc);
1867  $rcp_bc = implode(',', $rcp_bc);
1868 
1869 
1870  if (! ilMail::_usePearMail() )
1871  {
1872  // REPLACE ALL LOGIN NAMES WITH '@' BY ANOTHER CHARACTER
1873  $rcp_to = $this->__substituteRecipients($rcp_to,"substitute");
1874  $rcp_cc = $this->__substituteRecipients($rcp_cc,"substitute");
1875  $rcp_bc = $this->__substituteRecipients($rcp_bc,"substitute");
1876  }
1877 
1878  // COUNT EMAILS
1879  $c_emails = $this->__getCountRecipients($rcp_to,$rcp_cc,$rcp_bc,true);
1880  $c_rcp = $this->__getCountRecipients($rcp_to,$rcp_cc,$rcp_bc,false);
1881 
1882  // currently disabled..
1883  /*
1884  if (count($c_emails))
1885  {
1886  if (!$this->getEmailOfSender())
1887  {
1888  return $lng->txt("mail_check_your_email_addr");
1889  }
1890  }
1891  */
1892 
1893  // check smtp permission
1894  if($c_emails && $this->user_id != ANONYMOUS_USER_ID &&
1895  !$rbacsystem->checkAccessOfUser($this->user_id, 'smtp_mail', $this->mail_obj_ref_id))
1896  {
1897  return $this->lng->txt('mail_no_permissions_write_smtp');
1898  }
1899 
1900  if($this->appendInstallationSignature())
1901  {
1902  $a_m_message .= self::_getInstallationSignature();
1903  }
1904 
1905  // save mail in sent box
1906  $sent_id = $this->saveInSentbox($a_attachment,$a_rcp_to,$a_rcp_cc,$a_rcp_bc,$a_type,
1907  $a_m_subject,$a_m_message);
1908 
1909  if($a_attachment)
1910  {
1911  $this->mfile->assignAttachmentsToDirectory($sent_id,$sent_id);
1912 
1913  if ($error = $this->mfile->saveFiles($sent_id,$a_attachment))
1914  {
1915  return $error;
1916  }
1917  }
1918 
1919  // FILTER EMAILS
1920  // IF EMAIL RECIPIENT
1921  if($c_emails)
1922  {
1923  $this->sendMimeMail($this->__getEmailRecipients($rcp_to),
1924  $this->__getEmailRecipients($rcp_cc),
1925  $this->__getEmailRecipients($rcp_bc),
1926  $a_m_subject,
1927  $a_m_message,
1928  $a_attachment,
1929  0);
1930  }
1931 
1932  if (in_array('system',$a_type))
1933  {
1934  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))
1935  {
1936  return $lng->txt("mail_send_error");
1937  }
1938  }
1939  // ACTIONS FOR TYPE SYSTEM AND NORMAL
1940  if (in_array('normal',$a_type))
1941  {
1942  // TRY BOTH internal and email (depends on user settings)
1943  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))
1944  {
1945  return $lng->txt("mail_send_error");
1946  }
1947  }
1948 
1949  // Temporary bugfix
1950  if (!$this->getSaveInSentbox())
1951  {
1952  $this->deleteMails(array($sent_id));
1953  }
1954 
1955  return '';
1956  }
checkMail($a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_m_subject, $a_m_message, $a_type)
check if mail is complete, recipients are valid public
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)
send internal message to recipients private
__getCountRecipients($a_to, $a_cc, $a_bcc, $a_only_email=true)
checkRecipients($a_recipients, $a_type)
check if recipients are valid public
ILIAS Exception for Service Mail.
__substituteRecipients($a_rcp, $direction)
Note: This function can only be used, when ILIAS is configured to not use standards compliant mail ad...
getSaveInSentbox()
parseRcptOfMailingLists($rcpt='', $maintain_lists=false)
appendInstallationSignature($a_flag=null)
Setter/Getter for appending the installation signarue.
deleteMails($a_mail_ids)
delete mail public
__checkSystemRecipients(&$a_rcp_to)
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 All external mails are send to SOAP::sendMail starting a ki...
__getEmailRecipients($a_rcp)
saveInSentbox($a_attachment, $a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_type, $a_m_subject, $a_m_message)
send mime mail using class.ilMimeMail.php
+ Here is the call graph for this function:

◆ sendMimeMail()

ilMail::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 All external mails are send to SOAP::sendMail starting a kind of background process

Parameters
stringof recipients
stringof recipients
stringof recipients
stringsubject
stringmessage
arrayattachments
boolprevent soap public
Returns
array of saved data

Definition at line 2187 of file class.ilMail.php.

References $_COOKIE, and isSOAPEnabled().

Referenced by distributeMail(), and sendMail().

2188  {
2189  include_once "Services/Mail/classes/class.ilMimeMail.php";
2190 
2191  #var_dump("<pre>",$a_rcp_to,$a_rcp_cc,$a_rcp_bcc,$a_m_subject,$a_m_message,$a_attachments,"<pre>");
2192 
2193  #$inst_name = $this->ilias->getSetting("inst_name") ? $this->ilias->getSetting("inst_name") : "ILIAS 4";
2194  #$a_m_subject = "[".$inst_name."] ".$a_m_subject;
2195 
2196  $a_m_subject = self::getSubjectPrefix().' '.$a_m_subject;
2197 
2198  $sender = $this->getMimeMailSender();
2199 
2200  // #10854
2201  if($this->isSOAPEnabled() && !$a_no_soap)
2202  {
2203  // Send per soap
2204  include_once 'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
2205 
2206  $soap_client = new ilSoapClient();
2207  $soap_client->setResponseTimeout(1);
2208  $soap_client->enableWSDL(true);
2209  $soap_client->init();
2210 
2211  $attachments = array();
2212  $a_attachments = $a_attachments ? $a_attachments : array();
2213  foreach($a_attachments as $attachment)
2214  {
2215  $attachments[] = $this->mfile->getAbsolutePath($attachment);
2216  }
2217  // mjansen: switched separator from "," to "#:#" because of mantis bug #6039
2218  $attachments = implode('#:#',$attachments);
2219  // mjansen: use "#:#" as leading delimiter
2220  if(strlen($attachments))
2221  $attachments = "#:#".$attachments;
2222 
2223  $soap_client->call('sendMail',array(session_id().'::'.$_COOKIE['ilClientId'], // session id
2224  $a_rcp_to,
2225  $a_rcp_cc,
2226  $a_rcp_bcc,
2227  $sender,
2228  $a_m_subject,
2229  $a_m_message,
2230  $attachments));
2231 
2232  return true;
2233  }
2234  else
2235  {
2236  // send direct
2237  include_once "Services/Mail/classes/class.ilMimeMail.php";
2238 
2239  $mmail = new ilMimeMail();
2240  $mmail->autoCheck(false);
2241  $mmail->From($sender);
2242  $mmail->To($a_rcp_to);
2243  // Add installation name to subject
2244  $mmail->Subject($a_m_subject);
2245  $mmail->Body($a_m_message);
2246 
2247  if ($a_rcp_cc)
2248  {
2249  $mmail->Cc($a_rcp_cc);
2250  }
2251 
2252  if ($a_rcp_bcc)
2253  {
2254  $mmail->Bcc($a_rcp_bcc);
2255  }
2256 
2257  if (is_array($a_attachments))
2258  {
2259  foreach ($a_attachments as $attachment)
2260  {
2261  $mmail->Attach($this->mfile->getAbsolutePath($attachment), '', 'inline', $attachment);
2262  }
2263  }
2264 
2265  $mmail->Send();
2266  }
2267  }
isSOAPEnabled()
$_COOKIE["ilClientId"]
Definition: cron.php:11
this class encapsulates the PHP mail() function.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setMailMessage()

ilMail::setMailMessage (   $a_message)

Definition at line 435 of file class.ilMail.php.

436  {
437  $this->mail_message = $a_message;
438  }

◆ setMailRcpBc()

ilMail::setMailRcpBc (   $a_rcp_bc)

Definition at line 415 of file class.ilMail.php.

416  {
417  $this->mail_rcp_bc = $a_rcp_bc;
418  }

◆ setMailRcpCc()

ilMail::setMailRcpCc (   $a_rcp_cc)

Definition at line 405 of file class.ilMail.php.

406  {
407  $this->mail_rcp_cc = $a_rcp_cc;
408  }

◆ setMailRcpTo()

ilMail::setMailRcpTo (   $a_rcp_to)

Definition at line 395 of file class.ilMail.php.

396  {
397  $this->mail_rcp_to = $a_rcp_to;
398  }

◆ setMailSendType()

ilMail::setMailSendType (   $a_types)

Definition at line 385 of file class.ilMail.php.

386  {
387  $this->mail_send_type = $a_types;
388  }

◆ setMailSubject()

ilMail::setMailSubject (   $a_subject)

Definition at line 425 of file class.ilMail.php.

426  {
427  $this->mail_subject = $a_subject;
428  }

◆ setSaveInSentbox()

ilMail::setSaveInSentbox (   $a_save_in_sentbox)

Definition at line 370 of file class.ilMail.php.

Referenced by __construct(), and ilSoapUtils\distributeMails().

371  {
372  $this->save_in_sentbox = $a_save_in_sentbox;
373  }
+ Here is the caller graph for this function:

◆ setUsePear()

ilMail::setUsePear (   $bool)
private

Definition at line 2758 of file class.ilMail.php.

Referenced by validatePear().

2759  {
2760  $this->use_pear = $bool;
2761  }
+ Here is the caller graph for this function:

◆ updateDraft()

ilMail::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 
)

Definition at line 900 of file class.ilMail.php.

910  {
911  global $ilDB;
912 
913  $ilDB->update($this->table_mail,
914  array(
915  'folder_id' => array('integer', $a_folder_id),
916  'attachments' => array('clob', serialize($a_attachments)),
917  'send_time' => array('timestamp', date('Y-m-d H:i:s', time())),
918  'rcp_to' => array('clob', $a_rcp_to),
919  'rcp_cc' => array('clob', $a_rcp_cc),
920  'rcp_bcc' => array('clob', $a_rcp_bcc),
921  'm_status' => array('text', 'read'),
922  'm_type' => array('text', serialize($a_m_type)),
923  'm_email' => array('integer', $a_m_email),
924  'm_subject' => array('text', $a_m_subject),
925  'm_message' => array('clob', $a_m_message),
926  'use_placeholders' => array('integer', $a_use_placeholders)
927  ),
928  array(
929  'mail_id' => array('integer', $a_draft_id)
930  )
931  );
932 
933  return $a_draft_id;
934  }

◆ validatePear()

ilMail::validatePear (   $a_recipients)
private
Parameters
<type>$a_recipients

Definition at line 2773 of file class.ilMail.php.

References explodeRecipients(), and setUsePear().

Referenced by __getCountRecipient(), checkRecipients(), getEmailsOfRecipients(), and getUserIds().

2774  {
2775  if(ilMail::_usePearMail())
2776  {
2777  $this->setUsePear(true);
2778  $tmp_names = $this->explodeRecipients($a_recipients, true);
2779  if(is_a($tmp_names, 'PEAR_Error'))
2780  {
2781  $this->setUsePear(false);
2782  }
2783  }
2784  else
2785  {
2786  $this->setUsePear(false);
2787  }
2788  }
explodeRecipients($a_recipients, $use_pear=true)
explode recipient string allowed seperators are &#39;,&#39; &#39;;&#39; &#39; &#39;
setUsePear($bool)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $appendInstallationSignature

ilMail::$appendInstallationSignature = false
protected

Definition at line 208 of file class.ilMail.php.

Referenced by appendInstallationSignature().

◆ $ilias

ilMail::$ilias

Definition at line 117 of file class.ilMail.php.

Referenced by __construct().

◆ $lng

ilMail::$lng

Definition at line 124 of file class.ilMail.php.

Referenced by __construct(), getSalutation(), replacePlaceholders(), and sendMail().

◆ $mail_counter

ilMail::$mail_counter

Definition at line 161 of file class.ilMail.php.

◆ $mail_data

ilMail::$mail_data

◆ $mail_message

ilMail::$mail_message

Definition at line 201 of file class.ilMail.php.

◆ $mail_obj_ref_id

ilMail::$mail_obj_ref_id

Definition at line 176 of file class.ilMail.php.

Referenced by getMailObjectReferenceId().

◆ $mail_options

ilMail::$mail_options

Definition at line 133 of file class.ilMail.php.

◆ $mail_rcp_bc

ilMail::$mail_rcp_bc

Definition at line 199 of file class.ilMail.php.

◆ $mail_rcp_cc

ilMail::$mail_rcp_cc

Definition at line 198 of file class.ilMail.php.

◆ $mail_rcp_to

ilMail::$mail_rcp_to

Definition at line 197 of file class.ilMail.php.

◆ $mail_send_type

ilMail::$mail_send_type

Definition at line 183 of file class.ilMail.php.

◆ $mail_subject

ilMail::$mail_subject

Definition at line 200 of file class.ilMail.php.

◆ $mail_to_global_roles

ilMail::$mail_to_global_roles = 0

Definition at line 205 of file class.ilMail.php.

◆ $mail_use_placeholders

ilMail::$mail_use_placeholders = 0

Definition at line 202 of file class.ilMail.php.

◆ $mfile

ilMail::$mfile

Definition at line 131 of file class.ilMail.php.

◆ $properties

ilMail::$properties = array()
protected

Definition at line 218 of file class.ilMail.php.

◆ $save_in_sentbox

ilMail::$save_in_sentbox

Definition at line 190 of file class.ilMail.php.

Referenced by getSaveInSentbox().

◆ $soap_enabled

ilMail::$soap_enabled = true

Definition at line 204 of file class.ilMail.php.

Referenced by isSOAPEnabled().

◆ $table_mail

ilMail::$table_mail

Definition at line 147 of file class.ilMail.php.

◆ $table_mail_saved

ilMail::$table_mail_saved

Definition at line 154 of file class.ilMail.php.

◆ $use_pear

ilMail::$use_pear = true
private

Definition at line 207 of file class.ilMail.php.

Referenced by explodeRecipients(), and getUsePear().

◆ $user_id

ilMail::$user_id

Definition at line 140 of file class.ilMail.php.

Referenced by addFullname(), and sendInternalMail().

◆ $userInstances

ilMail::$userInstances = array()
staticprotected

Definition at line 223 of file class.ilMail.php.


The documentation for this class was generated from the following file: