ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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 @access 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 @access 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())
 
 countMailsOfFolder ($a_folder_id)
 count all mails of a specific folder @access public More...
 
 deleteMailsOfFolder ($a_folder_id)
 delete all mails of a specific folder @access public More...
 
 getMailCounterData ()
 get mail counter data returns data array with indexes "total","read","unread" @access public More...
 
 getMail ($a_mail_id)
 get data of one mail @access public More...
 
 markRead ($a_mail_ids)
 mark mails as read @access public More...
 
 markUnread ($a_mail_ids)
 mark mails as unread @access public More...
 
 moveMailsToFolder ($a_mail_ids, $a_folder_id)
 move mail to folder @access public More...
 
 deleteMails ($a_mail_ids)
 delete mail @access public More...
 
 fetchMailData ($a_row)
 fetch all query data from table mail @access 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 @access 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 @access 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 @access public More...
 
 getEmailsOfRecipients ($a_rcp)
 get email addresses of recipients @access public More...
 
 checkRecipients ($a_recipients)
 check if recipients are valid @access 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 @access public More...
 
 getSavedData ()
 get saved data @access public More...
 
 validateRecipients ($a_rcp_to, $a_rcp_cc, $a_rcp_bc)
 
 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 @access public More...
 
 saveAttachments ($a_attachments)
 set attachments More...
 
 getAttachments ()
 get attachments @access 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)
 
 __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 _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
 
const ILIAS_HOST = 'ilias'
 

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@ilias #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" <h2>Non-compliant e-mail addresses </h2> 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@mail.com 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 @access public.

Parameters
integeruser_id

Reimplemented in ilFormatMail.

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

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

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

+ Here is the call graph for this function:

Member Function Documentation

◆ __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 268 of file class.ilMail.php.

269 {
270 global $ilUser;
271
272 if(isset($this->properties[$name]))
273 {
274 return $this->properties[$name];
275 }
276
277 // Used to include files / instantiate objects at runtime
278 if($name == 'mlists')
279 {
280 if(is_object($ilUser))
281 {
282 require_once 'Services/Contact/classes/class.ilMailingLists.php';
283 $this->properties[$name] = new ilMailingLists($ilUser);
284 return $this->properties[$name];
285 }
286 }
287 }

References $ilUser.

◆ __getCountRecipient()

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

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

2391 {
2392 $counter = 0;
2393
2394 $this->validatePear($rcp);
2395 if (ilMail::_usePearMail() && $this->getUsePear())
2396 {
2397 $tmp_rcp = $this->explodeRecipients($rcp);
2398 if (! is_a($tmp_rcp, 'PEAR_Error'))
2399 {
2400 foreach ($tmp_rcp as $to)
2401 {
2402 if ($a_only_email)
2403 {
2404 // Fixed mantis bug #5875
2405 if(ilObjUser::_lookupId($to->mailbox.'@'.$to->host))
2406 {
2407 continue;
2408 }
2409
2410 // Addresses which aren't on the self::ILIAS_HOST host, and
2411 // which have a mailbox which does not start with '#',
2412 // are external e-mail addresses
2413 if ($to->host != 'ilias' && substr($to->mailbox,0,1) != '#' && substr($to->mailbox,0,2) != '"#')
2414 {
2415 ++$counter;
2416 }
2417 }
2418 else
2419 {
2420 ++$counter;
2421 }
2422 }
2423 }
2424 }
2425 else
2426 {
2427 foreach ($this->explodeRecipients($rcp,$this->getUsePear()) as $to)
2428 {
2429 if ($a_only_email)
2430 {
2431 $to = $this->__substituteRecipients($to,"resubstitute");
2432 if (strpos($to,'@'))
2433 {
2434 // Fixed mantis bug #5875
2435 if(ilObjUser::_lookupId($to))
2436 {
2437 continue;
2438 }
2439
2440 ++$counter;
2441 }
2442 }
2443 else
2444 {
2445 ++$counter;
2446 }
2447 }
2448 }
2449 return $counter;
2450 }
explodeRecipients($a_recipients, $use_pear=true)
explode recipient string allowed seperators are ',' ';' ' '
__substituteRecipients($a_rcp, $direction)
Note: This function can only be used, when ILIAS is configured to not use standards compliant mail ad...
validatePear($a_recipients)
static _lookupId($a_user_str)
lookup id by login

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

Referenced by __getCountRecipients().

+ 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 2453 of file class.ilMail.php.

2454 {
2455 return $this->__getCountRecipient($a_to,$a_only_email)
2456 + $this->__getCountRecipient($a_cc,$a_only_email)
2457 + $this->__getCountRecipient($a_bcc,$a_only_email);
2458 }
__getCountRecipient($rcp, $a_only_email=true)

References __getCountRecipient().

Referenced by sendMail().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __getEmailRecipients()

ilMail::__getEmailRecipients (   $a_rcp)

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

2461 {
2462 if (ilMail::_usePearMail())
2463 {
2464 $rcp = array();
2465 $tmp_rcp = $this->explodeRecipients($a_rcp);
2466 if (! is_a($tmp_rcp, 'PEAR_Error'))
2467 {
2468 foreach ($tmp_rcp as $to)
2469 {
2470 if(substr($to->mailbox,0,1) != '#' && substr($to->mailbox,0,2) != '"#' && $to->host != 'ilias')
2471 {
2472 // Fixed mantis bug #5875
2473 if(ilObjUser::_lookupId($to->mailbox.'@'.$to->host))
2474 {
2475 continue;
2476 }
2477
2478 $rcp[] = $to->mailbox.'@'.$to->host;
2479 }
2480 }
2481 }
2482 return implode(',',$rcp);
2483 }
2484 else
2485 {
2486 foreach ($this->explodeRecipients($a_rcp) as $to)
2487 {
2488 $to = $this->__substituteRecipients($to,"resubstitute");
2489 if(strpos($to,'@'))
2490 {
2491 // Fixed mantis bug #5875
2492 if(ilObjUser::_lookupId($to))
2493 {
2494 continue;
2495 }
2496
2497 $rcp[] = $to;
2498 }
2499 }
2500 return implode(',',$rcp ? $rcp : array());
2501 }
2502 }

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

Referenced by sendMail().

+ 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 2504 of file class.ilMail.php.

2505 {
2506 $inst_name = $this->ilias->getSetting("inst_name") ? $this->ilias->getSetting("inst_name") : "ILIAS 3";
2507
2508 $message = $inst_name." To:".$rcp_to."\n";
2509
2510 if ($rcp_cc)
2511 {
2512 $message .= "Cc: ".$rcp_cc;
2513 }
2514
2515 $message .= "\n\n";
2516 $message .= $a_m_message;
2517
2518 return $message;
2519 }

◆ __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 2528 of file class.ilMail.php.

2529 {
2530 $new_name = array();
2531
2532 $tmp_names = $this->explodeRecipients($a_rcp);
2533
2534
2535 foreach($tmp_names as $name)
2536 {
2537 if(strpos($name,"#") === 0)
2538 {
2539 $new_name[] = $name;
2540 continue;
2541 }
2542 switch($direction)
2543 {
2544 case "substitute":
2545 if(strpos($name,"@") and ilObjUser::_loginExists($name))
2546 {
2547 $new_name[] = preg_replace("/@/","�#�",$name);
2548 }
2549 else
2550 {
2551 $new_name[] = $name;
2552 }
2553 break;
2554
2555 case "resubstitute":
2556 if(stristr($name,"�#�"))
2557 {
2558 $new_name[] = preg_replace("/�#�/","@",$name);
2559 }
2560 else
2561 {
2562 $new_name[] = $name;
2563 }
2564 break;
2565 }
2566 }
2567 return implode(",",$new_name);
2568 }
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...

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

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

+ 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

@access public

Parameters
stringlanguage

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

2637 {
2638 global $ilSetting;
2639
2640 if(!$lang)
2641 {
2642 include_once('./Services/Language/classes/class.ilLanguageFactory.php');
2644 }
2645 $http_path = ilUtil::_getHttpPath();
2646
2647 $lang->loadLanguageModule('mail');
2648 return sprintf($lang->txt('mail_auto_generated_info'),
2649 $ilSetting->get('inst_name','ILIAS 5'),
2650 $http_path)."\n\n";
2651 }
static _getLanguage($a_lang_key='')
Get langauge object.
static _getHttpPath()
global $ilSetting
Definition: privfeed.php:40

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

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

+ 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.

@access public

Returns
string The installation mail signature

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

2706 {
2707 global $ilClientIniFile;
2708
2709 $signature = "\n\n* * * * *\n";
2710
2711 $signature .= $ilClientIniFile->readVariable('client', 'name')."\n";
2712 if(strlen($desc = $ilClientIniFile->readVariable('client', 'description')))
2713 {
2714 $signature .= $desc."\n";
2715 }
2716
2717 $signature .= ilUtil::_getHttpPath();
2718
2719 $clientdirs = glob(ILIAS_WEB_DIR."/*", GLOB_ONLYDIR);
2720 if(is_array($clientdirs) && count($clientdirs) > 1)
2721 {
2722 // #18051
2723 $signature .= '/login.php?client_id='.CLIENT_ID;
2724 }
2725
2726 $signature .= "\n\n";
2727
2728 return $signature;
2729 }
const ILIAS_WEB_DIR

References ilUtil\_getHttpPath(), and ILIAS_WEB_DIR.

Referenced by ilForum\__formatMessage(), ilSystemNotification\compose(), ilMailSummaryNotification\send(), ilPaymentNotification\send(), ilCronDeleteInactiveUserReminderMailNotification\send(), sendMail(), and ilObjSurveyGUI\sendUserResultsMail().

+ 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
lastname@access public

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

2586 {
2587 if (ilMail::_usePearMail())
2588 {
2589 if ($login == null)
2590 {
2591 require_once './Services/User/classes/class.ilObjUser.php';
2592 $usr_obj = self::getCachedUserInstance($usr_id);
2593 $login = $usr_obj->getLogin();
2594 $firstname = $usr_obj->getFirstname();
2595 $lastname = $usr_obj->getLastname();
2596 }
2597 // The following line of code creates a properly formatted mailbox
2598 // address. Unfortunately, it does not work, because ILIAS removes
2599 // everything between '<' '>' characters
2600 // Therefore, we just return the login - sic.
2601 // FIXME - Make this work in a future release
2602 /*
2603 return preg_replace('/[()<>@,;:\\".\[\]]/','',$firstname.' '.$lastname).' <'.$login.'>';
2604 */
2605 return $login.'hhho';
2606 }
2607 else
2608 {
2609 return $login;
2610 }
2611 }
static getCachedUserInstance($a_usr_id)
Returns a cached instance of ilObjUser.

References getCachedUserInstance().

+ Here is the call graph for this function:

◆ addFullname()

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

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

2118 {
2119 include_once 'Services/Mail/classes/class.ilMimeMail.php';
2120 return ilMimeMail::_mimeEncode($a_fullname).' <'.$a_email.'>';
2121 }
_mimeEncode($a_string)

References ilMimeMail\_mimeEncode().

+ Here is the call graph for this function:

◆ appendInstallationSignature()

ilMail::appendInstallationSignature (   $a_flag = null)

Setter/Getter for appending the installation signarue.

@access public

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

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

2687 {
2688 if(null === $a_flag) {
2690 }
2691
2692 $this->appendInstallationSignature = $a_flag;
2693
2694 return $this;
2695 }
appendInstallationSignature($a_flag=null)
Setter/Getter for appending the installation signarue.
$appendInstallationSignature

References $appendInstallationSignature, and appendInstallationSignature().

Referenced by appendInstallationSignature(), and sendMail().

+ Here is the call graph for this function:
+ 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 @access public

Parameters
stringrcp_to
stringrcp_cc
stringrcp_bcc
stringm_subject
stringm_message
Returns
string error message

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

1389 {
1390 $error_message = '';
1391
1392 $a_m_subject = trim($a_m_subject);
1393 $a_rcp_to = trim($a_rcp_to);
1394
1395 if (empty($a_m_subject))
1396 {
1397 $error_message .= $error_message ? "<br>" : '';
1398 $error_message .= $this->lng->txt("mail_add_subject");
1399 }
1400
1401 if (empty($a_rcp_to))
1402 {
1403 $error_message .= $error_message ? "<br>" : '';
1404 $error_message .= $this->lng->txt("mail_add_recipient");
1405 }
1406
1407 return $error_message;
1408 }

Referenced by sendMail().

+ Here is the caller graph for this function:

◆ checkRecipients()

ilMail::checkRecipients (   $a_recipients)

check if recipients are valid @access 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 1516 of file class.ilMail.php.

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

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

Referenced by validateRecipients().

+ 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 @access public

Parameters
integerid of folder
Returns
bool number of mails

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

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

References $ilDB, and $res.

◆ deleteMails()

ilMail::deleteMails (   $a_mail_ids)

delete mail @access public

Parameters
arraymail ids
Returns
bool

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

858 {
859 global $ilDB;
860
861 foreach ($a_mail_ids as $id)
862 {
863 $statement = $ilDB->manipulateF("
864 DELETE FROM ". $this->table_mail ."
865 WHERE user_id = %s
866 AND mail_id = %s ",
867 array('integer', 'integer'),
868 array($this->user_id, $id));
869
870 $this->mfile->deassignAttachmentFromDirectory($id);
871 }
872
873 return true;
874 }

References $ilDB.

Referenced by deleteMailsOfFolder(), and sendMail().

+ Here is the caller graph for this function:

◆ deleteMailsOfFolder()

ilMail::deleteMailsOfFolder (   $a_folder_id)

delete all mails of a specific folder @access public

Parameters
integerid of folder

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

652 {
653 if ($a_folder_id)
654 {
655 global $ilDB;
656
657 /*$statement = $ilDB->manipulateF("
658 DELETE FROM ". $this->table_mail ."
659 WHERE user_id = %s
660 AND folder_id = %s",
661 array('integer', 'integer'),
662 array($this->user_id, $a_folder_id));*/
663 $mails = $this->getMailsOfFolder($a_folder_id);
664 foreach((array)$mails as $mail_data)
665 {
666 $this->deleteMails(array($mail_data['mail_id']));
667 }
668
669 return true;
670 }
671
672 return false;
673 }
getMailsOfFolder($a_folder_id, $filter=array())
deleteMails($a_mail_ids)
delete mail @access public

References $ilDB, $mail_data, deleteMails(), and getMailsOfFolder().

+ 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 @access 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 1061 of file class.ilMail.php.

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

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

Referenced by sendMail().

+ 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 289 of file class.ilMail.php.

290 {
291 if(self::_usePearMail())
292 {
293 $recipients = $this->explodeRecipients($a_existing_recipients);
294 if(is_a($recipients, 'PEAR_Error'))
295 {
296 return false;
297 }
298 else
299 {
300 foreach($recipients as $rcp)
301 {
302 if (substr($rcp->mailbox, 0, 1) != '#')
303 {
304 if(trim($rcp->mailbox) == trim($a_recipient) ||
305 trim($rcp->mailbox.'@'.$rcp->host) == trim($a_recipient))
306 {
307 return true;
308 }
309 }
310 else if (substr($rcp->mailbox, 0, 7) == '#il_ml_')
311 {
312 if(trim($rcp->mailbox.'@'.$rcp->host) == trim($a_recipient))
313 {
314 return true;
315 }
316 }
317 else
318 {
319 if(trim($rcp->mailbox.'@'.$rcp->host) == trim($a_recipient))
320 {
321 return true;
322 }
323 }
324 }
325 }
326 }
327 else
328 {
329 $recipients = $this->explodeRecipients($a_existing_recipients);
330 if(count($recipients))
331 {
332 foreach($recipients as $recipient)
333 {
334 if(trim($recipient) == trim($a_recipient))
335 {
336 return true;
337 }
338 }
339 }
340 }
341
342 return false;
343 }

References explodeRecipients().

+ Here is the call graph for this function:

◆ enableSOAP()

ilMail::enableSOAP (   $a_status)

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

353 {
354 $this->soap_enabled = $a_status;
355 }

◆ explodeRecipients()

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

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

Returns an array with recipient objects

@access 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 2358 of file class.ilMail.php.

2359 {
2360 $a_recipients = trim($a_recipients);
2361
2362 // WHITESPACE IS NOT ALLOWED AS SEPERATOR
2363 #$a_recipients = preg_replace("/ /",",",$a_recipients);
2364 $a_recipients = preg_replace("/;/",",",$a_recipients);
2365
2366 if (ilMail::_usePearMail() && $use_pear == true)
2367 {
2368 if (strlen(trim($a_recipients)) > 0)
2369 {
2370 require_once './Services/PEAR/lib/Mail/RFC822.php';
2371 $parser = new Mail_RFC822();
2372 return $parser->parseAddressList($a_recipients, self::ILIAS_HOST, false, true);
2373 } else {
2374 return array();
2375 }
2376 }
2377 else
2378 {
2379 foreach(explode(',',$a_recipients) as $tmp_rec)
2380 {
2381 if($tmp_rec)
2382 {
2383 $rcps[] = trim($tmp_rec);
2384 }
2385 }
2386 return is_array($rcps) ? $rcps : array();
2387 }
2388 }

References $use_pear.

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

+ Here is the caller graph for this function:

◆ fetchMailData()

ilMail::fetchMailData (   $a_row)

fetch all query data from table mail @access public

Parameters
objectobject of query
Returns
array array of query data

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

883 {
884 if (!$a_row) return;
885
886 return array(
887 "mail_id" => $a_row->mail_id,
888 "user_id" => $a_row->user_id,
889 "folder_id" => $a_row->folder_id,
890 "sender_id" => $a_row->sender_id,
891 "attachments" => unserialize(stripslashes($a_row->attachments)),
892 "send_time" => $a_row->send_time,
893 "rcp_to" => $a_row->rcp_to,
894 "rcp_cc" => $a_row->rcp_cc,
895 "rcp_bcc" => $a_row->rcp_bcc,
896 "m_status" => $a_row->m_status,
897 "m_type" => unserialize(stripslashes($a_row->m_type)),
898 "m_email" => $a_row->m_email,
899 "m_subject" => $a_row->m_subject,
900 "m_message" => $a_row->m_message,
901 "import_name" => $a_row->import_name,
902 "use_placeholders"=> $a_row->use_placeholders);
903 }

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

+ 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

@access public

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

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

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

+ Here is the call graph for this function:

◆ getAttachments()

ilMail::getAttachments ( )

get attachments @access public

Returns
array array of attachments

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

2341 {
2342 return $this->mail_data["attachments"] ? $this->mail_data["attachments"] : array();
2343 }

◆ getCachedUserInstance()

static ilMail::getCachedUserInstance (   $a_usr_id)
staticprotected

Returns a cached instance of ilObjUser.

Parameters
integer$a_usr_id
Returns
ilObjUser

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

2811 {
2812 if(isset(self::$userInstances[$a_usr_id]))
2813 {
2814 return self::$userInstances[$a_usr_id];
2815 }
2816
2817 self::$userInstances[$a_usr_id] = new ilObjUser($a_usr_id);
2818 return self::$userInstances[$a_usr_id];
2819 }

Referenced by _getUserInternalMailboxAddress(), distributeMail(), formatNamesForOutput(), getEmailOfSender(), getEmailsOfRecipients(), and replacePlaceholders().

+ Here is the caller graph for this function:

◆ getEmailOfSender()

ilMail::getEmailOfSender ( )

get email of sender @access public

Returns
string email

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

2297 {
2298 $umail = self::getCachedUserInstance($this->user_id);
2299 $sender = $umail->getEmail();
2300
2301 if (ilUtil::is_email($sender))
2302 {
2303 return $sender;
2304 }
2305 else
2306 {
2307 return '';
2308 }
2309 }

References getCachedUserInstance(), and ilUtil\is_email().

+ Here is the call graph for this function:

◆ getEmailsOfRecipients()

ilMail::getEmailsOfRecipients (   $a_rcp)

get email addresses of recipients @access public

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

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

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

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

+ Here is the call graph for this function:

◆ getIliasMailerAddress()

static ilMail::getIliasMailerAddress ( )
static

Builds an email address used for system notifications.

@access public

Returns
string

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

2169 {
2170 global $ilSetting;
2171
2172 include_once 'Services/Mail/classes/class.ilMimeMail.php';
2173
2174 $no_reply_adress = trim($ilSetting->get('mail_external_sender_noreply'));
2175 if(strlen($no_reply_adress))
2176 {
2177 if(strpos($no_reply_adress, '@') === false)
2178 $no_reply_adress = 'noreply@'.$no_reply_adress;
2179
2180 if(!ilUtil::is_email($no_reply_adress))
2181 {
2182 $no_reply_adress = 'noreply@'.$_SERVER['SERVER_NAME'];
2183 }
2184
2185 $sender = ilMimeMail::_mimeEncode(self::_getIliasMailerName()).
2186 ' <'.$no_reply_adress.'>';
2187 }
2188 else
2189 {
2190 $sender = ilMimeMail::_mimeEncode(self::_getIliasMailerName()).
2191 ' <noreply@'.$_SERVER['SERVER_NAME'].'>';
2192 }
2193
2194 return $sender;
2195 }

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

Referenced by ilMailSummaryNotification\send(), ilPasswordAssistanceGUI\sendPasswordAssistanceMail(), and ilPasswordAssistanceGUI\sendUsernameAssistanceMail().

+ 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 @access public

Parameters
intmail_id
Returns
array mail_data

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

696 {
697 global $ilDB;
698
699 $res = $ilDB->queryf("
700 SELECT * FROM ". $this->table_mail ."
701 WHERE user_id = %s
702 AND mail_id = %s",
703 array('integer', 'integer'),
704 array($this->user_id, $a_mail_id));
705
706 $this->mail_data =$this->fetchMailData($res->fetchRow(DB_FETCHMODE_OBJECT));
707
708 return $this->mail_data;
709 }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
fetchMailData($a_row)
fetch all query data from table mail @access public

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

+ Here is the call graph for this function:

◆ getMailCounterData()

ilMail::getMailCounterData ( )

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

Returns
array mail_counter data

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

682 {
683 return is_array($this->mail_counter) ? $this->mail_counter : array(
684 "total" => 0,
685 "read" => 0,
686 "unread" => 0);
687 }

◆ getMailObjectReferenceId()

ilMail::getMailObjectReferenceId ( )

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

456 {
458 }

References $mail_obj_ref_id.

◆ getMailsOfFolder()

ilMail::getMailsOfFolder (   $a_folder_id,
  $filter = array() 
)
get all mails of a specific folder
@access     public
@param      integer id of folder
Parameters
arrayoptional filter array
Returns
array mails

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

575 {
576 global $ilDB;
577
578 $this->mail_counter = array();
579 $this->mail_counter['read'] = 0;
580 $this->mail_counter['unread'] = 0;
581
582 $query = "SELECT sender_id, m_subject, mail_id, m_status, send_time FROM ". $this->table_mail ."
583 LEFT JOIN object_data ON obj_id = sender_id
584 WHERE user_id = %s
585 AND folder_id = %s
586 AND ((sender_id > 0 AND sender_id IS NOT NULL AND obj_id IS NOT NULL) OR (sender_id = 0 OR sender_id IS NULL)) ";
587
588 if($filter['status'])
589 {
590 $query .= ' AND m_status = '.$ilDB->quote($filter['status'], 'text');
591 }
592 if($filter['type'])
593 {
594 $query .= ' AND '.$ilDB->like('m_type', 'text', '%%:"'.$filter['type'].'"%%', false);
595 }
596
597 $query .= " ORDER BY send_time DESC";
598
599 $res = $ilDB->queryf($query,
600 array('integer', 'integer'),
601 array($this->user_id, $a_folder_id));
602
603 while ($row = $ilDB->fetchObject($res))
604 {
605 $tmp = $this->fetchMailData($row);
606
607 if($tmp['m_status'] == 'read')
608 {
609 ++$this->mail_counter['read'];
610 }
611
612 if($tmp['m_status'] == 'unread')
613 {
614 ++$this->mail_counter['unread'];
615 }
616
617 $output[] = $tmp;
618 }
619
620 $this->mail_counter['total'] = count($output);
621
622 return $output ? $output : array();
623 }

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

Referenced by deleteMailsOfFolder().

+ 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 548 of file class.ilMail.php.

549 {
550 global $ilDB;
551
552 $ilDB->setLimit(1);
553 $res = $ilDB->queryf("
554 SELECT b.* FROM " . $this->table_mail ." a
555 INNER JOIN ".$this->table_mail ." b ON b.folder_id = a.folder_id
556 AND b.user_id = a.user_id AND b.send_time < a.send_time
557 WHERE a.user_id = %s
558 AND a.mail_id = %s ORDER BY b.send_time DESC",
559 array('integer', 'integer'),
560 array($this->user_id, $a_mail_id));
561
562 $this->mail_data = $this->fetchMailData($res->fetchRow(DB_FETCHMODE_OBJECT));
563
564 return $this->mail_data;
565 }

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

+ Here is the call graph for this function:

◆ getPreviousMail()

ilMail::getPreviousMail (   $a_mail_id)

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

530 {
531 global $ilDB;
532
533 $ilDB->setLimit(1);
534 $res = $ilDB->queryf("
535 SELECT b.* FROM " . $this->table_mail ." a
536 INNER JOIN ".$this->table_mail ." b ON b.folder_id = a.folder_id
537 AND b.user_id = a.user_id AND b.send_time > a.send_time
538 WHERE a.user_id = %s
539 AND a.mail_id = %s ORDER BY b.send_time ASC",
540 array('integer', 'integer'),
541 array($this->user_id, $a_mail_id));
542
543 $this->mail_data = $this->fetchMailData($res->fetchRow(DB_FETCHMODE_OBJECT));
544
545 return $this->mail_data;
546 }

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

+ 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 2748 of file class.ilMail.php.

2749 {
2750 global $lng;
2751
2752 $lang = $a_language ? $a_language : $lng;
2753
2754 $lang->loadLanguageModule('mail');
2755 $gender = ilObjUser::_lookupGender($a_usr_id);
2756 $gender = $gender ? $gender : 'n';
2757 $name = ilObjUser::_lookupName($a_usr_id);
2758
2759 if(!strlen($name['firstname']))
2760 {
2761 return $lang->txt('mail_salutation_anonymous').',';
2762 }
2763
2764 return $lang->txt('mail_salutation_'.$gender).' '.
2765 ($name['title'] ? $name['title'].' ' : '').
2766 ($name['firstname'] ? $name['firstname'].' ' : '').
2767 $name['lastname'].',';
2768 }
static _lookupGender($a_user_id)
Lookup gender.
static _lookupName($a_user_id)
lookup user name

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

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSavedData()

ilMail::getSavedData ( )

get saved data @access public

Returns
array of saved data

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

1733 {
1734 global $ilDB;
1735
1736 $res = $ilDB->queryf('
1737 SELECT * FROM '. $this->table_mail_saved .'
1738 WHERE user_id = %s',
1739 array('integer'),
1740 array($this->user_id));
1741
1742 $this->mail_data = $this->fetchMailData($res->fetchRow(DB_FETCHMODE_OBJECT));
1743
1744 return $this->mail_data;
1745 }

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

Referenced by savePostData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSaveInSentbox()

ilMail::getSaveInSentbox ( )

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

381 {
383 }

References $save_in_sentbox.

Referenced by sendMail().

+ 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 2735 of file class.ilMail.php.

2736 {
2737 global $ilSetting;
2738 static $prefix = null;
2739
2740 return $prefix == null ? $ilSetting->get('mail_subject_prefix','') : $prefix;
2741 }

References $ilSetting.

Referenced by sendMimeMail(), and ilMimeMail\Subject().

+ Here is the caller graph for this function:

◆ getUsePear()

ilMail::getUsePear ( )
private

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

2776 {
2777 return $this->use_pear;
2778 }

References $use_pear.

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

+ 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 1278 of file class.ilMail.php.

1279 {
1280 global $log, $rbacreview;
1281 $ids = array();
1282
1283 $this->validatePear($a_recipients);
1284 if (ilMail::_usePearMail() && $this->getUsePear() == true)
1285 {
1286 $tmp_names = $this->explodeRecipients($a_recipients );
1287 if (! is_a($tmp_names, 'PEAR_Error'))
1288 {
1289 for ($i = 0;$i < count($tmp_names); $i++)
1290 {
1291 if (substr($tmp_names[$i]->mailbox,0,1) == '#' || substr($tmp_names[$i]->mailbox,0,2) == '"#')
1292 {
1293 $role_ids = $rbacreview->searchRolesByMailboxAddressList($tmp_names[$i]->mailbox.'@'.$tmp_names[$i]->host);
1294 foreach($role_ids as $role_id)
1295 {
1296 foreach($rbacreview->assignedUsers($role_id) as $usr_id)
1297 {
1298 $ids[] = $usr_id;
1299 }
1300 }
1301 }
1302 else if (strtolower($tmp_names[$i]->host) == self::ILIAS_HOST)
1303 {
1304 if ($id = ilObjUser::getUserIdByLogin(addslashes($tmp_names[$i]->mailbox)))
1305 {
1306 //$log->write('class.ilMail->getUserIds() recipient:'.$tmp_names[$i]->mailbox.'@'.$tmp_names[$i]->host.' user_id:'.$id);
1307 $ids[] = $id;
1308 }
1309 else
1310 {
1311 //$log->write('class.ilMail->getUserIds() no user account found for recipient:'.$tmp_names[$i]->mailbox.'@'.$tmp_names[$i]->host);
1312 }
1313 }
1314 else
1315 {
1316 // Fixed mantis bug #5875
1317 if($id = ilObjUser::_lookupId($tmp_names[$i]->mailbox.'@'.$tmp_names[$i]->host))
1318 {
1319 $ids[] = $id;
1320 }
1321 else
1322 {
1323 //$log->write('class.ilMail->getUserIds() external recipient:'.$tmp_names[$i]->mailbox.'@'.$tmp_names[$i]->host);
1324 }
1325 }
1326 }
1327 }
1328 else
1329 {
1330 //$log->write('class.ilMail->getUserIds() illegal recipients:'.$a_recipients);
1331 }
1332 }
1333 else
1334 {
1335 $tmp_names = $this->explodeRecipients($a_recipients, $this->getUsePear());
1336 for ($i = 0;$i < count($tmp_names); $i++)
1337 {
1338 if (substr($tmp_names[$i],0,1) == '#' || substr($tmp_names[$i], 0, 2) == '"#')
1339 {
1340 if(ilUtil::groupNameExists(addslashes(substr($tmp_names[$i],1))))
1341 {
1342 include_once("./Services/Object/classes/class.ilObjectFactory.php");
1343 include_once('./Modules/Group/classes/class.ilObjGroup.php');
1344
1345 foreach(ilObject::_getAllReferences(ilObjGroup::_lookupIdByTitle(addslashes(substr($tmp_names[$i],1)))) as $ref_id)
1346 {
1348 break;
1349 }
1350 // STORE MEMBER IDS IN $ids
1351 foreach ($grp_object->getGroupMemberIds() as $id)
1352 {
1353 $ids[] = $id;
1354 }
1355 }
1356 // is role: get role ids
1357 elseif($role_id = $rbacreview->roleExists(addslashes(substr($tmp_names[$i],1))))
1358 {
1359 foreach($rbacreview->assignedUsers($role_id) as $usr_id)
1360 {
1361 $ids[] = $usr_id;
1362 }
1363 }
1364
1365 }
1366 else if (!empty($tmp_names[$i]))
1367 {
1368 if ($id = ilObjUser::getUserIdByLogin(addslashes($tmp_names[$i])))
1369 {
1370 $ids[] = $id;
1371 }
1372 }
1373 }
1374 }
1375 return array_unique($ids);
1376 }

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

Referenced by distributeMail().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isSOAPEnabled()

ilMail::isSOAPEnabled ( )

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

357 {
358 global $ilSetting;
359
360 if(!extension_loaded('curl') || !$ilSetting->get('soap_user_administration'))
361 {
362 return false;
363 }
364
365 // Prevent using SOAP in cron context
367 {
368 return false;
369 }
370
371 return (bool) $this->soap_enabled;
372 }
const CONTEXT_CRON
static getType()
Get context type.

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

Referenced by sendMimeMail().

+ 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 @access public

Parameters
arraymail ids
Returns
bool

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

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

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

◆ markUnread()

ilMail::markUnread (   $a_mail_ids)

mark mails as unread @access public

Parameters
arraymail ids
Returns
bool

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

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

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

◆ moveMailsToFolder()

ilMail::moveMailsToFolder (   $a_mail_ids,
  $a_folder_id 
)

move mail to folder @access public

Parameters
arraymail ids
intfolder_id
Returns
bool

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

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

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

◆ parseRcptOfMailingLists()

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

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

1972 {
1973 if ($rcpt == '')
1974 {
1975 if(!$maintain_lists)
1976 {
1977 return $rcpt;
1978 }
1979 else
1980 {
1981 return array();
1982 }
1983 }
1984//@todo check rcp pear validation
1985 $arrRcpt = $this->explodeRecipients(trim($rcpt));
1986 if (!is_array($arrRcpt) || empty($arrRcpt))
1987 {
1988 if(!$maintain_lists)
1989 {
1990 return $rcpt;
1991 }
1992 else
1993 {
1994 return array();
1995 }
1996 }
1997
1998 $new_rcpt = array();
1999
2000 foreach ($arrRcpt as $item)
2001 {
2002 if (ilMail::_usePearMail())
2003 {
2004 if (substr($item->mailbox, 0, 7) == '#il_ml_')
2005 {
2006 if ($this->mlists->mailingListExists($item->mailbox))
2007 {
2008 foreach ($this->mlists->getCurrentMailingList()->getAssignedEntries() as $entry)
2009 {
2010 if(!$maintain_lists)
2011 {
2012 $new_rcpt[] = ($entry['login'] != '' ? $entry['login'] : $entry['email']);
2013 }
2014 else
2015 {
2016 $new_rcpt[$item->mailbox][] = ($entry['login'] != '' ? $entry['login'] : $entry['email']);
2017 }
2018 }
2019 }
2020 }
2021 else
2022 {
2023 $tmp_rcpt = '';
2024 if($item->host == self::ILIAS_HOST)
2025 {
2026 $tmp_rcpt = $item->mailbox;
2027 }
2028 else
2029 {
2030 $tmp_rcpt = $item->mailbox.'@'.$item->host;
2031 }
2032
2033 if(!$maintain_lists)
2034 {
2035 $new_rcpt[] = $tmp_rcpt;
2036 }
2037 else
2038 {
2039 $new_rcpt[0][] = $tmp_rcpt;
2040 }
2041 }
2042 }
2043 else
2044 {
2045 if (substr($item, 0, 7) == '#il_ml_')
2046 {
2047 if ($this->mlists->mailingListExists($item))
2048 {
2049 foreach ($this->mlists->getCurrentMailingList()->getAssignedEntries() as $entry)
2050 {
2051 if(!$maintain_lists)
2052 {
2053 $new_rcpt[] = ($entry['login'] != '' ? $entry['login'] : $entry['email']);
2054 }
2055 else
2056 {
2057 $new_rcpt[$item][] = ($entry['login'] != '' ? $entry['login'] : $entry['email']);
2058 }
2059 }
2060 }
2061 }
2062 else
2063 {
2064 if(!$maintain_lists)
2065 {
2066 $new_rcpt[] = $item;
2067 }
2068 else
2069 {
2070 $new_rcpt[0][] = $item;
2071 }
2072 }
2073 }
2074 }
2075
2076 if(!$maintain_lists)
2077 {
2078 return implode(',', $new_rcpt);
2079 }
2080 else
2081 {
2082 return $new_rcpt;
2083 }
2084 }

References explodeRecipients().

Referenced by sendMail().

+ 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 @access private

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

450 {
451 include_once 'Services/Mail/classes/class.ilMailGlobalServices.php';
452 $this->mail_obj_ref_id = ilMailGlobalServices::getMailObjectRefId();
453 }
static getMailObjectRefId()
Determines the reference id of the mail object and stores this information in a local cache variable.

References ilMailGlobalServices\getMailObjectRefId().

Referenced by __construct().

+ 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 1023 of file class.ilMail.php.

1024 {
1025 global $lng;
1026
1027 $user = self::getCachedUserInstance($a_user_id);
1028
1029 // determine salutation
1030 switch ($user->getGender())
1031 {
1032 case 'f': $gender_salut = $lng->txt('salutation_f');
1033 break;
1034 case 'm': $gender_salut = $lng->txt('salutation_m');
1035 break;
1036 }
1037
1038 $a_message = str_replace('[MAIL_SALUTATION]', $gender_salut, $a_message);
1039 $a_message = str_replace('[LOGIN]', $user->getLogin(), $a_message);
1040 $a_message = str_replace('[FIRST_NAME]', $user->getFirstname(), $a_message);
1041 $a_message = str_replace('[LAST_NAME]', $user->getLastname(), $a_message);
1042 $a_message = str_replace('[ILIAS_URL]', ILIAS_HTTP_PATH.'/login.php?client_id='.CLIENT_ID, $a_message);
1043 $a_message = str_replace('[CLIENT_NAME]', CLIENT_NAME, $a_message);
1044
1045 return $a_message;
1046 }

References $lng, and getCachedUserInstance().

Referenced by distributeMail(), and sendInternalMail().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveAttachments()

ilMail::saveAttachments (   $a_attachments)

set attachments

Parameters
arrayarray of attachments @access public
Returns
bool

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

2318 {
2319 global $ilDB;
2320
2321 $ilDB->update($this->table_mail_saved,
2322 array
2323 (
2324 'attachments' => array('clob', serialize($a_attachments))
2325 ),
2326 array
2327 (
2328 'user_id' => array('integer', $this->user_id)
2329 )
2330 );
2331
2332 return true;
2333 }

References $ilDB.

◆ 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 @access public
Returns
int mail id
Todo:
: mjansen 23.12.2011 Why is $a_as_email undefined here?

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

2100 {
2101 include_once "Services/Mail/classes/class.ilMailbox.php";
2102
2103 $mbox = new ilMailbox($this->user_id);
2104 $sent_id = $mbox->getSentFolder();
2105
2107 return $this->sendInternalMail($sent_id,$this->user_id,$a_attachment,$a_rcp_to,$a_rcp_cc,
2108 $a_rcp_bcc,'read',$a_type,$a_as_email,$a_m_subject,$a_m_message,$this->user_id, 0);
2109 }

References sendInternalMail().

Referenced by sendMail().

+ 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 @access 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 1680 of file class.ilMail.php.

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

References $ilDB, and getSavedData().

+ Here is the call 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 @access 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 958 of file class.ilMail.php.

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

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

Referenced by distributeMail(), and saveInSentbox().

+ 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) @access public
Returns
array of saved data

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

1799 {
1800 global $lng,$rbacsystem,$log;
1801 //$log->write('class.ilMail.sendMail '.$a_rcp_to.' '.$a_m_subject);
1802
1803 $this->mail_to_global_roles = true;
1804 if($this->user_id != ANONYMOUS_USER_ID)
1805 {
1806 $this->mail_to_global_roles = $rbacsystem->checkAccessOfUser($this->user_id, 'mail_to_global_roles', $this->mail_obj_ref_id);
1807 }
1808
1809 if (in_array("system",$a_type))
1810 {
1811 $a_type = array('system');
1812 }
1813
1814 if ($a_attachment)
1815 {
1816 if (!$this->mfile->checkFilesExist($a_attachment))
1817 {
1818 return "YOUR LIST OF ATTACHMENTS IS NOT VALID, PLEASE EDIT THE LIST";
1819 }
1820 }
1821 // CHECK NECESSARY MAIL DATA FOR ALL TYPES
1822 if ($error_message = $this->checkMail($a_rcp_to,$a_rcp_cc,$a_rcp_bc,$a_m_subject,$a_m_message,$a_type))
1823 {
1824 return $error_message;
1825 }
1826
1827 $error_message = $this->validateRecipients($a_rcp_to, $a_rcp_cc, $a_rcp_bc);
1828 if(strlen($error_message) > 0)
1829 {
1830 return $error_message;
1831 }
1832
1833 // ACTIONS FOR ALL TYPES
1834
1835
1836 // GET RCPT OF MAILING LISTS
1837
1838 $rcp_to_list = $this->parseRcptOfMailingLists($a_rcp_to, true);
1839 $rcp_cc_list = $this->parseRcptOfMailingLists($a_rcp_cc, true);
1840 $rcp_bc_list = $this->parseRcptOfMailingLists($a_rcp_bc, true);
1841
1842 $rcp_to = $rcp_cc = $rcp_bc = array();
1843 foreach($rcp_to_list as $mlist_id => $mlist_rec)
1844 {
1845 if($mlist_id)
1846 {
1847 // internal mailing lists are sent as bcc
1848 $mlist_id = substr($mlist_id, 7);
1849 if($this->mlists->get($mlist_id)->getMode() == ilMailingList::MODE_TEMPORARY)
1850 {
1851 $rcp_bc = array_merge($rcp_bc, $mlist_rec);
1852 continue;
1853 }
1854 }
1855
1856 $rcp_to = array_merge($rcp_to, $mlist_rec);
1857 }
1858 foreach($rcp_cc_list as $mlist_id => $mlist_rec)
1859 {
1860 if($mlist_id)
1861 {
1862 // internal mailing lists are sent as bcc
1863 $mlist_id = substr($mlist_id, 7);
1864 if($this->mlists->get($mlist_id)->getMode() == ilMailingList::MODE_TEMPORARY)
1865 {
1866 $rcp_bc = array_merge($rcp_bc, $mlist_rec);
1867 continue;
1868 }
1869 }
1870
1871 $rcp_cc = array_merge($rcp_cc, $mlist_rec);
1872 }
1873 foreach($rcp_bc_list as $mlist_id => $mlist_rec)
1874 {
1875 $rcp_bc = array_merge($rcp_bc, $mlist_rec);
1876 }
1877
1878 $rcp_to = implode(',', $rcp_to);
1879 $rcp_cc = implode(',', $rcp_cc);
1880 $rcp_bc = implode(',', $rcp_bc);
1881
1882
1883 if (! ilMail::_usePearMail() )
1884 {
1885 // REPLACE ALL LOGIN NAMES WITH '@' BY ANOTHER CHARACTER
1886 $rcp_to = $this->__substituteRecipients($rcp_to,"substitute");
1887 $rcp_cc = $this->__substituteRecipients($rcp_cc,"substitute");
1888 $rcp_bc = $this->__substituteRecipients($rcp_bc,"substitute");
1889 }
1890
1891 // COUNT EMAILS
1892 $c_emails = $this->__getCountRecipients($rcp_to,$rcp_cc,$rcp_bc,true);
1893 $c_rcp = $this->__getCountRecipients($rcp_to,$rcp_cc,$rcp_bc,false);
1894
1895 // currently disabled..
1896 /*
1897 if (count($c_emails))
1898 {
1899 if (!$this->getEmailOfSender())
1900 {
1901 return $lng->txt("mail_check_your_email_addr");
1902 }
1903 }
1904 */
1905
1906 // check smtp permission
1907 if($c_emails && $this->user_id != ANONYMOUS_USER_ID &&
1908 !$rbacsystem->checkAccessOfUser($this->user_id, 'smtp_mail', $this->mail_obj_ref_id))
1909 {
1910 return $this->lng->txt('mail_no_permissions_write_smtp');
1911 }
1912
1913 if($this->appendInstallationSignature())
1914 {
1915 $a_m_message .= self::_getInstallationSignature();
1916 }
1917
1918 // save mail in sent box
1919 $sent_id = $this->saveInSentbox($a_attachment,$a_rcp_to,$a_rcp_cc,$a_rcp_bc,$a_type,
1920 $a_m_subject,$a_m_message);
1921
1922 if($a_attachment)
1923 {
1924 $this->mfile->assignAttachmentsToDirectory($sent_id,$sent_id);
1925
1926 if ($error = $this->mfile->saveFiles($sent_id,$a_attachment))
1927 {
1928 return $error;
1929 }
1930 }
1931
1932 // FILTER EMAILS
1933 // IF EMAIL RECIPIENT
1934 if($c_emails)
1935 {
1936 $this->sendMimeMail($this->__getEmailRecipients($rcp_to),
1937 $this->__getEmailRecipients($rcp_cc),
1938 $this->__getEmailRecipients($rcp_bc),
1939 $a_m_subject,
1940 $a_m_message,
1941 $a_attachment,
1942 0);
1943 }
1944
1945 if (in_array('system',$a_type))
1946 {
1947 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))
1948 {
1949 return $lng->txt("mail_send_error");
1950 }
1951 }
1952 // ACTIONS FOR TYPE SYSTEM AND NORMAL
1953 if (in_array('normal',$a_type))
1954 {
1955 // TRY BOTH internal and email (depends on user settings)
1956 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))
1957 {
1958 return $lng->txt("mail_send_error");
1959 }
1960 }
1961
1962 // Temporary bugfix
1963 if (!$this->getSaveInSentbox())
1964 {
1965 $this->deleteMails(array($sent_id));
1966 }
1967
1968 return '';
1969 }
parseRcptOfMailingLists($rcpt='', $maintain_lists=false)
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 @access private
__getEmailRecipients($a_rcp)
__getCountRecipients($a_to, $a_cc, $a_bcc, $a_only_email=true)
static _getInstallationSignature()
Static getter for the installation signature.
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
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 @access public
validateRecipients($a_rcp_to, $a_rcp_cc, $a_rcp_bc)
getSaveInSentbox()

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

+ 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 @access public
Returns
array of saved data

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

2211 {
2212 include_once "Services/Mail/classes/class.ilMimeMail.php";
2213
2214 #var_dump("<pre>",$a_rcp_to,$a_rcp_cc,$a_rcp_bcc,$a_m_subject,$a_m_message,$a_attachments,"<pre>");
2215
2216 #$inst_name = $this->ilias->getSetting("inst_name") ? $this->ilias->getSetting("inst_name") : "ILIAS 4";
2217 #$a_m_subject = "[".$inst_name."] ".$a_m_subject;
2218
2219 $a_m_subject = self::getSubjectPrefix().' '.$a_m_subject;
2220
2221 $sender = $this->getMimeMailSender();
2222
2223 // #10854
2224 if($this->isSOAPEnabled() && !$a_no_soap)
2225 {
2226 // Send per soap
2227 include_once 'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
2228
2229 $soap_client = new ilSoapClient();
2230 $soap_client->setResponseTimeout(1);
2231 $soap_client->enableWSDL(true);
2232 $soap_client->init();
2233
2234 $attachments = array();
2235 $a_attachments = $a_attachments ? $a_attachments : array();
2236 foreach($a_attachments as $attachment)
2237 {
2238 $attachments[] = $this->mfile->getAbsolutePath($attachment);
2239 }
2240 // mjansen: switched separator from "," to "#:#" because of mantis bug #6039
2241 $attachments = implode('#:#',$attachments);
2242 // mjansen: use "#:#" as leading delimiter
2243 if(strlen($attachments))
2244 $attachments = "#:#".$attachments;
2245
2246 $soap_client->call('sendMail',array(session_id().'::'.$_COOKIE['ilClientId'], // session id
2247 $a_rcp_to,
2248 $a_rcp_cc,
2249 $a_rcp_bcc,
2250 $sender,
2251 $a_m_subject,
2252 $a_m_message,
2253 $attachments));
2254
2255 return true;
2256 }
2257 else
2258 {
2259 // send direct
2260 include_once "Services/Mail/classes/class.ilMimeMail.php";
2261
2262 $mmail = new ilMimeMail();
2263 $mmail->autoCheck(false);
2264 $mmail->From($sender);
2265 $mmail->To($a_rcp_to);
2266 // Add installation name to subject
2267 $mmail->Subject($a_m_subject);
2268 $mmail->Body($a_m_message);
2269
2270 if ($a_rcp_cc)
2271 {
2272 $mmail->Cc($a_rcp_cc);
2273 }
2274
2275 if ($a_rcp_bcc)
2276 {
2277 $mmail->Bcc($a_rcp_bcc);
2278 }
2279
2280 if (is_array($a_attachments))
2281 {
2282 foreach ($a_attachments as $attachment)
2283 {
2284 $mmail->Attach($this->mfile->getAbsolutePath($attachment), '', 'inline', $attachment);
2285 }
2286 }
2287
2288 $mmail->Send();
2289 }
2290 }
isSOAPEnabled()
static getSubjectPrefix()
Get text that will be prepended to auto generated mails.
this class encapsulates the PHP mail() function.
$_COOKIE["ilClientId"]
Definition: cron.php:11

References $_COOKIE, getSubjectPrefix(), and isSOAPEnabled().

Referenced by distributeMail(), and sendMail().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setMailMessage()

ilMail::setMailMessage (   $a_message)

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

441 {
442 $this->mail_message = $a_message;
443 }

◆ setMailRcpBc()

ilMail::setMailRcpBc (   $a_rcp_bc)

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

421 {
422 $this->mail_rcp_bc = $a_rcp_bc;
423 }

◆ setMailRcpCc()

ilMail::setMailRcpCc (   $a_rcp_cc)

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

411 {
412 $this->mail_rcp_cc = $a_rcp_cc;
413 }

◆ setMailRcpTo()

ilMail::setMailRcpTo (   $a_rcp_to)

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

401 {
402 $this->mail_rcp_to = $a_rcp_to;
403 }

◆ setMailSendType()

ilMail::setMailSendType (   $a_types)

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

391 {
392 $this->mail_send_type = $a_types;
393 }

◆ setMailSubject()

ilMail::setMailSubject (   $a_subject)

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

431 {
432 $this->mail_subject = $a_subject;
433 }

◆ setSaveInSentbox()

ilMail::setSaveInSentbox (   $a_save_in_sentbox)

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

376 {
377 $this->save_in_sentbox = $a_save_in_sentbox;
378 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setUsePear()

ilMail::setUsePear (   $bool)
private

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

2771 {
2772 $this->use_pear = $bool;
2773 }

Referenced by validatePear().

+ 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 905 of file class.ilMail.php.

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

References $ilDB.

◆ validatePear()

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

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

2786 {
2787 if(ilMail::_usePearMail())
2788 {
2789 $this->setUsePear(true);
2790 $tmp_names = $this->explodeRecipients($a_recipients, true);
2791 if(is_a($tmp_names, 'PEAR_Error'))
2792 {
2793 $this->setUsePear(false);
2794 }
2795 }
2796 else
2797 {
2798 $this->setUsePear(false);
2799 }
2800 }
setUsePear($bool)

References explodeRecipients(), and setUsePear().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ validateRecipients()

ilMail::validateRecipients (   $a_rcp_to,
  $a_rcp_cc,
  $a_rcp_bc 
)
Parameters
string$a_rcp_to
string$a_rcp_cc
string$a_rcp_bc
Returns
string

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

1754 {
1755 try
1756 {
1757 $message = '';
1758
1759 if($error_message = $this->checkRecipients($a_rcp_to))
1760 {
1761 $message .= $error_message;
1762 }
1763 if($error_message = $this->checkRecipients($a_rcp_cc))
1764 {
1765 $message .= $error_message;
1766 }
1767 if($error_message = $this->checkRecipients($a_rcp_bc))
1768 {
1769 $message .= $error_message;
1770 }
1771
1772 if(strlen($message) > 0)
1773 {
1774 return $this->lng->txt('mail_following_rcp_not_valid') . $message;
1775 }
1776
1777 return '';
1778 }
1779 catch(ilMailException $e)
1780 {
1781 return $this->lng->txt('mail_following_rcp_not_valid') . $this->lng->txt($e->getMessage());
1782 }
1783 }
checkRecipients($a_recipients)
check if recipients are valid @access public

References checkRecipients().

Referenced by sendMail().

+ 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

◆ $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 223 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 checkRecipients(), and sendInternalMail().

◆ $userInstances

ilMail::$userInstances = array()
staticprotected

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

◆ ILIAS_HOST

const ilMail::ILIAS_HOST = 'ilias'

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