ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilMail Class Reference
+ Inheritance diagram for ilMail:
+ Collaboration diagram for ilMail:

Public Member Functions

 __construct ( $a_user_id, ilMailAddressTypeFactory $mailAddressTypeFactory=null, ilMailRfc822AddressParserFactory $mailAddressParserFactory=null, \ilAppEventHandler $eventHandler=null)
 
 withContextId (string $contextId)
 
 withContextParameters (array $parameters)
 
 __get ($name)
 Magic interceptor method __get Used to include files / instantiate objects at runtime. More...
 
 existsRecipient (string $newRecipient, string $existingRecipients)
 
 enableSOAP ($a_status)
 Define if external mails should be sent using SOAP client or not. More...
 
 isSOAPEnabled ()
 
 setSaveInSentbox ($a_save_in_sentbox)
 
 getSaveInSentbox ()
 
 getMailObjectReferenceId ()
 
 formatNamesForOutput ($a_recipients)
 Prepends the fullname of each ILIAS login name (if 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)
 
 deleteMailsOfFolder ($a_folder_id)
 
 getMail ($a_mail_id)
 
 markRead (array $a_mail_ids)
 
 markUnread (array $a_mail_ids)
 
 moveMailsToFolder (array $mailIds, int $folderId)
 
 deleteMails (array $mailIds)
 
 getNewDraftId ($usrId, $folderId)
 
 updateDraft ( $a_folder_id, $a_attachments, $a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_m_type, $a_m_email, $a_m_subject, $a_m_message, $a_draft_id=0, $a_use_placeholders=0, $a_tpl_context_id=null, $a_tpl_context_params=array())
 
 savePostData ( $a_user_id, $a_attachments, $a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_m_type, $a_m_email, $a_m_subject, $a_m_message, $a_use_placeholders, $a_tpl_context_id=null, $a_tpl_ctx_params=array())
 save post data in table public More...
 
 getSavedData ()
 
 sendMail ($a_rcp_to, $a_rcp_cc, $a_rcp_bc, $a_m_subject, $a_m_message, $a_attachment, $a_type, $a_use_placeholders=0)
 Should be used to send notifcations over the internal or external mail channel. More...
 
 validateRecipients (string $to, string $cc, string $bcc)
 
 saveAttachments ($a_attachments)
 
 appendInstallationSignature ($a_flag=null)
 Setter/Getter for appending the installation signarue. More...
 
 formatLinebreakMessage ($a_message)
 

Static Public Member Functions

static _getAutoGeneratedMessageString (ilLanguage $lang=null)
 Get auto generated info string. More...
 
static _getInstallationSignature ()
 
static getSubjectPrefix ()
 Get text that will be prepended to auto generated mails. More...
 
static getSalutation ($a_usr_id, ilLanguage $a_language=null)
 

Data Fields

const ILIAS_HOST = 'ilias'
 
const MAIL_SUBJECT_PREFIX = '[ILIAS]'
 
 $user_id
 

Protected Member Functions

 isSystemMail ()
 
 readMailObjectReferenceId ()
 Read and set the mail object ref id (administration node) More...
 
 fetchMailData ($a_row)
 
 replacePlaceholders ($a_message, $a_user_id=0, $replace_empty=true)
 
 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)
 
 getUserIds (array $recipients)
 
 checkMail (string $to, string $cc, string $bcc, string $subject)
 
 checkRecipients (string $recipients)
 Check if recipients are valid. More...
 
 saveInSentbox ($a_attachment, $a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_type, $a_m_subject, $a_m_message)
 Stores a message in the sent bod of the current user. More...
 
 parseAddresses ($addresses)
 Explode recipient string, allowed separators are ',' ';' ' ' Returns an array with recipient ilMailAddress instances. More...
 
 getCountRecipient (string $recipients, $onlyExternalAddresses=true)
 
 getCountRecipients (string $toRecipients, string $ccRecipients, string $bccRecipients, $onlyExternalAddresses=true)
 
 getEmailRecipients (string $recipients)
 

Static Protected Member Functions

static getCachedUserInstance ($a_usr_id)
 

Protected Attributes

 $lng
 
 $db
 
 $mfile
 
 $mail_options
 
 $mailbox
 
 $table_mail
 
 $table_mail_saved
 
 $mail_data = array()
 
 $mail_obj_ref_id
 
 $save_in_sentbox
 
 $soap_enabled = true
 
 $appendInstallationSignature = false
 
 $properties = array()
 
 $contextId = null
 
 $contextParameters = []
 

Static Protected Attributes

static $userInstances = array()
 

Private Member Functions

 sendInternalMail ( $a_folder_id, $a_sender_id, $a_attachments, $a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_status, $a_m_type, $a_m_email, $a_m_subject, $a_m_message, $a_user_id=0, $a_use_placeholders=0, $a_tpl_context_id=null, $a_tpl_context_params=array())
 save mail in folder private More...
 

Private Attributes

 $eventHandler
 
 $mailAddressTypeFactory
 
 $mailAddressParserFactory
 

Detailed Description

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilMail::__construct (   $a_user_id,
ilMailAddressTypeFactory  $mailAddressTypeFactory = null,
ilMailRfc822AddressParserFactory  $mailAddressParserFactory = null,
\ilAppEventHandler  $eventHandler = null 
)
Parameters
integer$a_user_id
ilMailAddressTypeFactory | null$mailAddressTypeFactory
ilMailRfc822AddressParserFactory | null$mailAddressParserFactory
ilAppEventHandler | null$eventHandler

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

References $DIC, $eventHandler, $mailAddressParserFactory, $mailAddressTypeFactory, readMailObjectReferenceId(), and setSaveInSentbox().

91  {
92  global $DIC;
93 
94  require_once 'Services/Mail/classes/class.ilFileDataMail.php';
95  require_once 'Services/Mail/classes/class.ilMailOptions.php';
96 
97  if ($mailAddressTypeFactory === null) {
98  $mailAddressTypeFactory = new ilMailAddressTypeFactory();
99  }
100 
101  if ($mailAddressParserFactory === null) {
102  $mailAddressParserFactory = new ilMailRfc822AddressParserFactory();
103  }
104 
105  if ($eventHandler === null) {
106  $eventHandler = $DIC->event();
107  }
108 
109  $this->mailAddressParserFactory = $mailAddressParserFactory;
110  $this->mailAddressTypeFactory = $mailAddressTypeFactory;
111  $this->eventHandler = $eventHandler;
112 
113  $this->lng = $DIC->language();
114  $this->db = $DIC->database();
115 
116  $this->lng->loadLanguageModule('mail');
117 
118  $this->table_mail = 'mail';
119  $this->table_mail_saved = 'mail_saved';
120 
121  $this->user_id = $a_user_id;
122 
123  $this->mfile = new ilFileDataMail($this->user_id);
124  $this->mail_options = new ilMailOptions($a_user_id);
125  $this->mailbox = new ilMailbox($this->user_id);
126 
127  $this->setSaveInSentbox(false);
128  $this->readMailObjectReferenceId();
129  }
Class ilMailOptions this class handles user mails.
global $DIC
Definition: saml.php:7
Class ilFileDataMail.
setSaveInSentbox($a_save_in_sentbox)
$mailAddressParserFactory
Class ilMailRfc822AddressParserFactory.
Mail Box class Base class for creating and handling mail boxes.
$mailAddressTypeFactory
Class ilMailAddressTypeFactory.
readMailObjectReferenceId()
Read and set the mail object ref id (administration node)
+ 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
string$nameThe name of the class property
Returns
ilMailingLists

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

References $DIC, and $name.

172  {
173  global $DIC;
174 
175  if (isset($this->properties[$name])) {
176  return $this->properties[$name];
177  }
178 
179  if ($name == 'mlists') {
180  if (is_object($DIC->user())) {
181  require_once 'Services/Contact/classes/class.ilMailingLists.php';
182  $this->properties[$name] = new ilMailingLists($DIC->user());
183  return $this->properties[$name];
184  }
185  }
186  }
global $DIC
Definition: saml.php:7

◆ _getAutoGeneratedMessageString()

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

Get auto generated info string.

Parameters
ilLanguage$lang
Returns
string;

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

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

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

1642  {
1643  global $DIC;
1644 
1645  if (!($lang instanceof ilLanguage)) {
1646  require_once 'Services/Language/classes/class.ilLanguageFactory.php';
1648  }
1649 
1650  $lang->loadLanguageModule('mail');
1651 
1652  return sprintf(
1653  $lang->txt('mail_auto_generated_info'),
1654  $DIC->settings()->get('inst_name', 'ILIAS 5'),
1656  ) . "\n\n";
1657  }
global $DIC
Definition: saml.php:7
static _getLanguage($a_lang_key='')
Get langauge object.
static _getHttpPath()
loadLanguageModule($a_module)
language handling
txt($a_topic, $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getInstallationSignature()

static ilMail::_getInstallationSignature ( )
static
Returns
string The installation mail signature

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

References $DIC, and ilUtil\_getHttpPath().

Referenced by ilRegistrationMimeMailNotification\__construct(), ilMailSummaryNotification\__construct(), ilForumMailNotification\addLinkToMail(), ilSystemNotification\compose(), ilTimingsCronReminder\fillObjectListForMailBody(), ilCronDeleteInactiveUserReminderMailNotification\send(), ilMailCronOrphanedMailsNotification\send(), ilAccountRegistrationMail\sendLanguageVariableBasedAccountMail(), and ilObjSurveyGUI\sendUserResultsMail().

1690  {
1691  global $DIC;
1692 
1693  $signature = $DIC->settings()->get('mail_system_sys_signature');
1694 
1695  $clientUrl = ilUtil::_getHttpPath();
1696  $clientdirs = glob(ILIAS_WEB_DIR . '/*', GLOB_ONLYDIR);
1697  if (is_array($clientdirs) && count($clientdirs) > 1) {
1698  $clientUrl .= '/login.php?client_id=' . CLIENT_ID; // #18051
1699  }
1700 
1701  $signature = str_ireplace('[CLIENT_NAME]', $DIC['ilClientIniFile']->readVariable('client', 'name'), $signature);
1702  $signature = str_ireplace('[CLIENT_DESC]', $DIC['ilClientIniFile']->readVariable('client', 'description'), $signature);
1703  $signature = str_ireplace('[CLIENT_URL]', $clientUrl, $signature);
1704 
1705  if (!preg_match('/^[\n\r]+/', $signature)) {
1706  $signature = "\n" . $signature;
1707  }
1708 
1709  return $signature;
1710  }
global $DIC
Definition: saml.php:7
static _getHttpPath()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ appendInstallationSignature()

ilMail::appendInstallationSignature (   $a_flag = null)

Setter/Getter for appending the installation signarue.

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

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

References $appendInstallationSignature.

Referenced by sendMail().

1677  {
1678  if (null === $a_flag) {
1680  }
1681 
1682  $this->appendInstallationSignature = $a_flag;
1683  return $this;
1684  }
$appendInstallationSignature
appendInstallationSignature($a_flag=null)
Setter/Getter for appending the installation signarue.
+ Here is the caller graph for this function:

◆ checkMail()

ilMail::checkMail ( string  $to,
string  $cc,
string  $bcc,
string  $subject 
)
protected
Parameters
string$to
string$cc
string$bcc
string$subject
Returns
[] An array of errors determined on validation

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

References $errors.

Referenced by sendMail().

1146  : array
1147  {
1148  $errors = [];
1149 
1150  foreach (array(
1151  $subject => 'mail_add_subject',
1152  $to => 'mail_add_recipient'
1153  ) as $string => $error) {
1154  if (0 === strlen($string)) {
1155  $errors[] = new \ilMailError($error);
1156  }
1157  }
1158 
1159  return $errors;
1160  }
$errors
Definition: index.php:6
+ Here is the caller graph for this function:

◆ checkRecipients()

ilMail::checkRecipients ( string  $recipients)
protected

Check if recipients are valid.

Parameters
string$recipients
Returns
[] An array of errors determined on validation
Exceptions

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

References $errors, and parseAddresses().

Referenced by validateRecipients().

1168  : array
1169  {
1170  $errors = [];
1171 
1172  try {
1173  $addresses = $this->parseAddresses($recipients);
1174  foreach ($addresses as $address) {
1175  $addressType = $this->mailAddressTypeFactory->getByPrefix($address);
1176  if (!$addressType->validate($this->user_id)) {
1177  $newErrors = $addressType->getErrors();
1178  $errors = array_merge($errors, $newErrors);
1179  }
1180  }
1181  } catch (\ilException $e) {
1182  $colonPosition = strpos($e->getMessage(), ':');
1183  throw new \ilMailException(
1184  ($colonPosition === false) ? $e->getMessage() : substr($e->getMessage(), $colonPosition + 2)
1185  );
1186  }
1187 
1188  return $errors;
1189  }
$errors
Definition: index.php:6
parseAddresses($addresses)
Explode recipient string, allowed separators are ',' ';' ' ' Returns an array with recipient ilMailAd...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ countMailsOfFolder()

ilMail::countMailsOfFolder (   $a_folder_id)
Parameters
int$a_folder_id
Returns
int

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

References $res.

390  {
391  $res = $this->db->queryF(
392  "
393  SELECT COUNT(*) FROM {$this->table_mail}
394  WHERE user_id = %s AND folder_id = %s",
395  array('integer', 'integer'),
396  array($this->user_id, $a_folder_id)
397  );
398 
399  return $this->db->numRows($res);
400  }
foreach($_POST as $key=> $value) $res

◆ deleteMails()

ilMail::deleteMails ( array  $mailIds)
Parameters
int[]$mailIds
Returns
bool

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

References $id.

Referenced by deleteMailsOfFolder(), and sendMail().

563  {
564  $mailIds = array_filter(array_map('intval', $mailIds));
565  foreach ($mailIds as $id) {
566  $this->db->manipulateF(
567  "
568  DELETE FROM {$this->table_mail} WHERE user_id = %s AND mail_id = %s",
569  array('integer', 'integer'),
570  array($this->user_id, $id)
571  );
572  $this->mfile->deassignAttachmentFromDirectory($id);
573  }
574 
575  return true;
576  }
if(!array_key_exists('StateId', $_REQUEST)) $id
+ Here is the caller graph for this function:

◆ deleteMailsOfFolder()

ilMail::deleteMailsOfFolder (   $a_folder_id)
Parameters
int$a_folder_idid of folder
Returns
bool

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

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

407  {
408  if ($a_folder_id) {
409  $mails = $this->getMailsOfFolder($a_folder_id);
410  foreach ((array) $mails as $mail_data) {
411  $this->deleteMails(array($mail_data['mail_id']));
412  }
413 
414  return true;
415  }
416 
417  return false;
418  }
getMailsOfFolder($a_folder_id, $filter=array())
deleteMails(array $mailIds)
+ 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 
)
protected
Parameters
string$a_rcp_to
string$a_rcp_cc
string$a_rcp_bcc
string$a_subject
string$a_message
array$a_attachments
integer$sent_mail_id
array$a_type
array$a_action
array | int$a_use_placeholders
Returns
bool

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

References $a_type, $email, $id, formatLinebreakMessage(), ilMailOptions\getExternalEmailsByUser(), ilLoggerFactory\getLogger(), getUserIds(), ilMailOptions\INCOMING_BOTH, ilMailOptions\INCOMING_EMAIL, replacePlaceholders(), sendInternalMail(), and ilStr\strLen().

Referenced by sendMail().

817  {
818  require_once 'Services/Mail/classes/class.ilMailbox.php';
819  require_once 'Services/User/classes/class.ilObjUser.php';
820 
821  $mbox = new ilMailbox();
822  if (!$a_use_placeholders) {
823  $rcp_ids = $this->getUserIds(array($a_rcp_to, $a_rcp_cc, $a_rcp_bcc));
824 
825  ilLoggerFactory::getLogger('mail')->debug(sprintf(
826  "Parsed TO/CC/BCC user ids from given recipients: %s",
827  implode(', ', $rcp_ids)
828  ));
829 
830  $as_email = array();
831 
832  foreach ($rcp_ids as $id) {
833  $tmp_mail_options = new ilMailOptions($id);
834 
835  $tmp_user = self::getCachedUserInstance($id);
836  $user_is_active = $tmp_user->getActive();
837  $user_can_read_internal_mails = !$tmp_user->hasToAcceptTermsOfService() && $tmp_user->checkTimeLimit();
838 
839  if (in_array('system', $a_type) && !$user_can_read_internal_mails) {
840  ilLoggerFactory::getLogger('mail')->debug(sprintf(
841  "Message is marked as 'system', skipped recipient with id %s (Accepted User Agreement:%s|Expired Account:%s)",
842  $id,
843  var_export(!$tmp_user->hasToAcceptTermsOfService(), 1),
844  var_export(!$tmp_user->checkTimeLimit(), 1)
845  ));
846  continue;
847  }
848 
849  if ($user_is_active) {
850  if (!$user_can_read_internal_mails
851  || $tmp_mail_options->getIncomingType() == ilMailOptions::INCOMING_EMAIL
852  || $tmp_mail_options->getIncomingType() == ilMailOptions::INCOMING_BOTH) {
853  $newEmailAddresses = ilMailOptions::getExternalEmailsByUser($tmp_user, $tmp_mail_options);
854  $as_email = array_unique(array_merge($newEmailAddresses, $as_email));
855 
856  if ($tmp_mail_options->getIncomingType() == ilMailOptions::INCOMING_EMAIL) {
857  ilLoggerFactory::getLogger('mail')->debug(sprintf(
858  "Recipient with id %s will only receive external emails sent to: %s",
859  $id,
860  implode(', ', $newEmailAddresses)
861  ));
862  continue;
863  } else {
864  ilLoggerFactory::getLogger('mail')->debug(sprintf(
865  "Recipient with id %s will additionally receive external emails sent to: %s",
866  $id,
867  implode(', ', $newEmailAddresses)
868  ));
869  }
870  }
871  }
872 
873  $mbox->setUserId($id);
874  $inbox_id = $mbox->getInboxFolder();
875 
876  $mail_id = $this->sendInternalMail(
877  $inbox_id,
878  $this->user_id,
879  $a_attachments,
880  $a_rcp_to,
881  $a_rcp_cc,
882  '',
883  'unread',
884  $a_type,
885  0,
886  $a_subject,
887  $a_message,
888  $id,
889  0
890  );
891 
892  if ($a_attachments) {
893  $this->mfile->assignAttachmentsToDirectory($mail_id, $sent_mail_id);
894  }
895  }
896 
897  $to = array();
898  $bcc = array();
899 
900  $as_email = array_values(array_unique($as_email));
901  if (count($as_email) == 1) {
902  $to[] = $as_email[0];
903  } else {
904  foreach ($as_email as $email) {
905  $bcc[] = $email;
906  }
907  }
908 
909  if (count($to) > 0) {
910  $this->sendMimeMail(implode(',', $to), '', implode(',', $bcc), $a_subject, $this->formatLinebreakMessage($a_message), $a_attachments);
911  } elseif (count($bcc) > 0) {
912  $remainingAddresses = '';
913  $maxRecipientCharacterLength = 998;
914  foreach ($bcc as $emailAddress) {
915  $sep = '';
916  if (strlen($remainingAddresses) > 0) {
917  $sep = ',';
918  }
919 
920  $recipientsLineLength = ilStr::strLen($remainingAddresses) + ilStr::strLen($sep . $emailAddress);
921  if ($recipientsLineLength >= $maxRecipientCharacterLength) {
922  $this->sendMimeMail(
923  '',
924  '',
925  $remainingAddresses,
926  $a_subject,
927  $this->formatLinebreakMessage($a_message),
928  $a_attachments
929  );
930 
931  $remainingAddresses = '';
932  $sep = '';
933  }
934 
935  $remainingAddresses .= ($sep . $emailAddress);
936  }
937 
938  if ('' !== $remainingAddresses) {
939  $this->sendMimeMail(
940  '',
941  '',
942  $remainingAddresses,
943  $a_subject,
944  $this->formatLinebreakMessage($a_message),
945  $a_attachments
946  );
947  }
948  }
949  } else {
950  $rcp_ids_replace = $this->getUserIds(array($a_rcp_to));
951  $rcp_ids_no_replace = $this->getUserIds(array($a_rcp_cc, $a_rcp_bcc));
952 
953  ilLoggerFactory::getLogger('mail')->debug(sprintf(
954  "Parsed TO user ids from given recipients for serial letter notification: %s",
955  implode(', ', $rcp_ids_replace)
956  ));
957  ilLoggerFactory::getLogger('mail')->debug(sprintf(
958  "Parsed CC/BCC user ids from given recipients for serial letter notification: %s",
959  implode(', ', $rcp_ids_no_replace)
960  ));
961 
962  $as_email = array();
963  $id_to_message_map = array();
964 
965  foreach ($rcp_ids_replace as $id) {
966  $tmp_mail_options = new ilMailOptions($id);
967 
968  $tmp_user = self::getCachedUserInstance($id);
969  $user_is_active = $tmp_user->getActive();
970  $user_can_read_internal_mails = !$tmp_user->hasToAcceptTermsOfService() && $tmp_user->checkTimeLimit();
971 
972  if (in_array('system', $a_type) && !$user_can_read_internal_mails) {
973  ilLoggerFactory::getLogger('mail')->debug(sprintf(
974  "Message is marked as 'system', skipped recipient with id %s (Accepted User Agreement:%s|Expired Account:%s)",
975  $id,
976  var_export(!$tmp_user->hasToAcceptTermsOfService(), 1),
977  var_export(!$tmp_user->checkTimeLimit(), 1)
978  ));
979  continue;
980  }
981 
982  $id_to_message_map[$id] = $this->replacePlaceholders($a_message, $id);
983 
984  if ($user_is_active) {
985  if (!$user_can_read_internal_mails
986  || $tmp_mail_options->getIncomingType() == ilMailOptions::INCOMING_EMAIL
987  || $tmp_mail_options->getIncomingType() == ilMailOptions::INCOMING_BOTH) {
988  $as_email[$tmp_user->getId()] = ilMailOptions::getExternalEmailsByUser($tmp_user, $tmp_mail_options);
989 
990  if ($tmp_mail_options->getIncomingType() == ilMailOptions::INCOMING_EMAIL) {
991  ilLoggerFactory::getLogger('mail')->debug(sprintf(
992  "Recipient with id %s will only receive external emails sent to: %s",
993  $id,
994  implode(', ', $as_email[$tmp_user->getId()])
995  ));
996  continue;
997  } else {
998  ilLoggerFactory::getLogger('mail')->debug(sprintf(
999  "Recipient with id %s will additionally receive external emails sent to: %s",
1000  $id,
1001  implode(', ', $as_email[$tmp_user->getId()])
1002  ));
1003  }
1004  }
1005  }
1006 
1007  $mbox->setUserId($id);
1008  $inbox_id = $mbox->getInboxFolder();
1009 
1010  $mail_id = $this->sendInternalMail(
1011  $inbox_id,
1012  $this->user_id,
1013  $a_attachments,
1014  $a_rcp_to,
1015  $a_rcp_cc,
1016  '',
1017  'unread',
1018  $a_type,
1019  0,
1020  $a_subject,
1021  $id_to_message_map[$id],
1022  $id,
1023  0
1024  );
1025 
1026  if ($a_attachments) {
1027  $this->mfile->assignAttachmentsToDirectory($mail_id, $sent_mail_id);
1028  }
1029  }
1030 
1031  if (count($as_email)) {
1032  foreach ($as_email as $id => $emails) {
1033  if (0 == count($emails)) {
1034  continue;
1035  }
1036 
1037  $toEmailAddresses = implode(',', $emails);
1038  $this->sendMimeMail($toEmailAddresses, '', '', $a_subject, $this->formatLinebreakMessage($id_to_message_map[$id]), $a_attachments);
1039  }
1040  }
1041 
1042  $as_email = array();
1043 
1044  $cc_and_bcc_message = $this->replacePlaceholders($a_message, 0, false);
1045 
1046  foreach ($rcp_ids_no_replace as $id) {
1047  $tmp_mail_options = new ilMailOptions($id);
1048 
1049  $tmp_user = self::getCachedUserInstance($id);
1050  $user_is_active = $tmp_user->getActive();
1051  $user_can_read_internal_mails = !$tmp_user->hasToAcceptTermsOfService() && $tmp_user->checkTimeLimit();
1052 
1053  if ($user_is_active) {
1054  if (in_array('system', $a_type) && !$user_can_read_internal_mails) {
1055  ilLoggerFactory::getLogger('mail')->debug(sprintf(
1056  "Message is marked as 'system', skipped recipient with id %s (Accepted User Agreement:%s|Expired Account:%s)",
1057  $id,
1058  var_export(!$tmp_user->hasToAcceptTermsOfService(), 1),
1059  var_export(!$tmp_user->checkTimeLimit(), 1)
1060  ));
1061  continue;
1062  }
1063 
1064 
1065  if (!$user_can_read_internal_mails
1066  || $tmp_mail_options->getIncomingType() == ilMailOptions::INCOMING_EMAIL
1067  || $tmp_mail_options->getIncomingType() == ilMailOptions::INCOMING_BOTH) {
1068  $newEmailAddresses = ilMailOptions::getExternalEmailsByUser($tmp_user, $tmp_mail_options);
1069  $as_email = array_unique(array_merge($newEmailAddresses, $as_email));
1070 
1071  if ($tmp_mail_options->getIncomingType() == ilMailOptions::INCOMING_EMAIL) {
1072  ilLoggerFactory::getLogger('mail')->debug(sprintf(
1073  "Recipient with id %s will only receive external emails sent to: %s",
1074  $id,
1075  implode(', ', $newEmailAddresses)
1076  ));
1077  continue;
1078  } else {
1079  ilLoggerFactory::getLogger('mail')->debug(sprintf(
1080  "Recipient with id %s will additionally receive external emails sent to: %s",
1081  $id,
1082  implode(', ', $newEmailAddresses)
1083  ));
1084  }
1085  }
1086  }
1087 
1088  $mbox->setUserId($id);
1089  $inbox_id = $mbox->getInboxFolder();
1090 
1091  $mail_id = $this->sendInternalMail(
1092  $inbox_id,
1093  $this->user_id,
1094  $a_attachments,
1095  $a_rcp_to,
1096  $a_rcp_cc,
1097  '',
1098  'unread',
1099  $a_type,
1100  0,
1101  $a_subject,
1102  $cc_and_bcc_message,
1103  $id,
1104  0
1105  );
1106 
1107  if ($a_attachments) {
1108  $this->mfile->assignAttachmentsToDirectory($mail_id, $sent_mail_id);
1109  }
1110  }
1111 
1112  if (count($as_email)) {
1113  $this->sendMimeMail('', '', implode(',', $as_email), $a_subject, $this->formatLinebreakMessage($cc_and_bcc_message), $a_attachments);
1114  }
1115  }
1116 
1117  return true;
1118  }
if($orgName !==null) if($spconfig->hasValue('contacts')) $email
Definition: metadata.php:201
Class ilMailOptions this class handles user mails.
static strLen($a_string)
Definition: class.ilStr.php:78
if(!array_key_exists('StateId', $_REQUEST)) $id
static getExternalEmailsByUser(ilObjUser $user, ilMailOptions $mail_options=null)
$a_type
Definition: workflow.php:92
Mail Box class Base class for creating and handling mail boxes.
formatLinebreakMessage($a_message)
replacePlaceholders($a_message, $a_user_id=0, $replace_empty=true)
sendInternalMail( $a_folder_id, $a_sender_id, $a_attachments, $a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_status, $a_m_type, $a_m_email, $a_m_subject, $a_m_message, $a_user_id=0, $a_use_placeholders=0, $a_tpl_context_id=null, $a_tpl_context_params=array())
save mail in folder private
getUserIds(array $recipients)
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ enableSOAP()

ilMail::enableSOAP (   $a_status)

Define if external mails should be sent using SOAP client or not.

The autogenerated mails in new user registration sets this value to false, since there is no valid session.

Parameters
bool$a_status

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

211  {
212  $this->soap_enabled = (bool) $a_status;
213  }

◆ existsRecipient()

ilMail::existsRecipient ( string  $newRecipient,
string  $existingRecipients 
)
Parameters
string$newRecipient
string$existingRecipients
Returns
bool

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

References $list, and parseAddresses().

193  : bool
194  {
195  $newAddresses = new \ilMailAddressListImpl($this->parseAddresses($newRecipient));
196  $addresses = new \ilMailAddressListImpl($this->parseAddresses($existingRecipients));
197 
198  $list = new \ilMailDiffAddressList($newAddresses, $addresses);
199 
200  $diffedAddresses = $list->value();
201 
202  return count($diffedAddresses) === 0;
203  }
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41
parseAddresses($addresses)
Explode recipient string, allowed separators are ',' ';' ' ' Returns an array with recipient ilMailAd...
+ Here is the call graph for this function:

◆ fetchMailData()

ilMail::fetchMailData (   $a_row)
protected
Parameters
array|null
Returns
array|null

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

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

583  {
584  if (!is_array($a_row) || empty($a_row)) {
585  return null;
586  }
587 
588  $a_row['attachments'] = unserialize(stripslashes($a_row['attachments']));
589  $a_row['m_type'] = unserialize(stripslashes($a_row['m_type']));
590  $a_row['tpl_ctx_params'] = (array) (@json_decode($a_row['tpl_ctx_params'], true));
591 
592  return $a_row;
593  }
+ Here is the caller graph for this function:

◆ formatLinebreakMessage()

ilMail::formatLinebreakMessage (   $a_message)

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

Referenced by distributeMail(), sendInternalMail(), and sendMail().

1773  {
1774  return $a_message;
1775  }
+ Here is the caller graph for this function:

◆ formatNamesForOutput()

ilMail::formatNamesForOutput (   $a_recipients)

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

Parameters
string$a_recipientsA string containing to, cc or bcc recipients
Returns
string

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

References $DIC, $user, ilObjUser\_lookupId(), and ilObjUser\_lookupPref().

273  {
274  global $DIC;
275 
276  $a_recipients = trim($a_recipients);
277  if (!strlen($a_recipients)) {
278  return $this->lng->txt('not_available');
279  }
280 
281  $names = array();
282 
283  $recipients = array_filter(array_map('trim', explode(',', $a_recipients)));
284  foreach ($recipients as $recipient) {
285  $usr_id = ilObjUser::_lookupId($recipient);
286  if ($usr_id > 0) {
287  $pp = ilObjUser::_lookupPref($usr_id, 'public_profile');
288  if ($pp == 'y' || ($pp == 'g' && !$DIC->user()->isAnonymous())) {
289  $user = self::getCachedUserInstance($usr_id);
290  $names[] = $user->getFullname() . ' [' . $recipient . ']';
291  continue;
292  }
293  }
294 
295  $names[] = $recipient;
296  }
297 
298  return implode(', ', $names);
299  }
global $DIC
Definition: saml.php:7
static _lookupId($a_user_str)
Lookup id by login.
$user
Definition: migrateto20.php:57
static _lookupPref($a_usr_id, $a_keyword)
+ Here is the call graph for this function:

◆ getCachedUserInstance()

static ilMail::getCachedUserInstance (   $a_usr_id)
staticprotected
Parameters
int$a_usr_id
Returns
ilObjUser

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

1760  {
1761  if (isset(self::$userInstances[$a_usr_id])) {
1762  return self::$userInstances[$a_usr_id];
1763  }
1764 
1765  self::$userInstances[$a_usr_id] = new ilObjUser($a_usr_id);
1766  return self::$userInstances[$a_usr_id];
1767  }

◆ getCountRecipient()

ilMail::getCountRecipient ( string  $recipients,
  $onlyExternalAddresses = true 
)
protected
Parameters
string$recipients
bool$onlyExternalAddresses
Returns
int

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

References parseAddresses().

Referenced by getCountRecipients().

1588  : int
1589  {
1590  $addresses = new \ilMailAddressListImpl($this->parseAddresses($recipients));
1591  if ($onlyExternalAddresses) {
1592  $addresses = new \ilMailOnlyExternalAddressList($addresses, self::ILIAS_HOST);
1593  }
1594 
1595  return count($addresses->value());
1596  }
parseAddresses($addresses)
Explode recipient string, allowed separators are ',' ';' ' ' Returns an array with recipient ilMailAd...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCountRecipients()

ilMail::getCountRecipients ( string  $toRecipients,
string  $ccRecipients,
string  $bccRecipients,
  $onlyExternalAddresses = true 
)
protected
Parameters
string$toRecipients
string$ccRecipients
$bccRecipients
bool$onlyExternalAddresses
Returns
int

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

References getCountRecipient().

Referenced by sendMail().

1610  : int {
1611  return (
1612  $this->getCountRecipient($toRecipients, $onlyExternalAddresses) +
1613  $this->getCountRecipient($ccRecipients, $onlyExternalAddresses) +
1614  $this->getCountRecipient($bccRecipients, $onlyExternalAddresses)
1615  );
1616  }
getCountRecipient(string $recipients, $onlyExternalAddresses=true)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getEmailRecipients()

ilMail::getEmailRecipients ( string  $recipients)
protected
Parameters
string$recipients
Returns
string

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

References parseAddresses().

Referenced by sendMail().

1622  : string
1623  {
1624  $addresses = new \ilMailOnlyExternalAddressList(
1625  new \ilMailAddressListImpl($this->parseAddresses($recipients)),
1626  self::ILIAS_HOST
1627  );
1628 
1629  $emailRecipients = array_map(function (\ilMailAddress $address) {
1630  return (string) $address;
1631  }, $addresses->value());
1632 
1633  return implode(',', $emailRecipients);
1634  }
Class ilMailAddress.
Class ilMailAddressListImpl.
parseAddresses($addresses)
Explode recipient string, allowed separators are ',' ';' ' ' Returns an array with recipient ilMailAd...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMail()

ilMail::getMail (   $a_mail_id)
Parameters
int$a_mail_id
Returns
array

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

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

425  {
426  $res = $this->db->queryF(
427  "
428  SELECT * FROM {$this->table_mail}
429  WHERE user_id = %s AND mail_id = %s",
430  array('integer', 'integer'),
431  array($this->user_id, $a_mail_id)
432  );
433 
434  $this->mail_data = $this->fetchMailData($this->db->fetchAssoc($res));
435 
436  return $this->mail_data;
437  }
foreach($_POST as $key=> $value) $res
fetchMailData($a_row)
+ Here is the call graph for this function:

◆ getMailObjectReferenceId()

ilMail::getMailObjectReferenceId ( )
Returns
int

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

References $mail_obj_ref_id.

262  {
263  return $this->mail_obj_ref_id;
264  }
$mail_obj_ref_id

◆ getMailsOfFolder()

ilMail::getMailsOfFolder (   $a_folder_id,
  $filter = array() 
)
Parameters
int$a_folder_idThe id of the folder
array$filterAn optional filter array
Returns
array

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

References Sabre\VObject\$output, $query, $res, $row, and fetchMailData().

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

353  {
354  $output = array();
355 
356  $query = "
357  SELECT sender_id, m_subject, mail_id, m_status, send_time FROM {$this->table_mail}
358  LEFT JOIN object_data ON obj_id = sender_id
359  WHERE user_id = %s AND folder_id = %s
360  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)) ";
361 
362  if (isset($filter['status']) && strlen($filter['status']) > 0) {
363  $query .= ' AND m_status = ' . $this->db->quote($filter['status'], 'text');
364  }
365 
366  if (isset($filter['type']) && strlen($filter['type']) > 0) {
367  $query .= ' AND ' . $this->db->like('m_type', 'text', '%%:"' . $filter['type'] . '"%%', false);
368  }
369 
370  $query .= " ORDER BY send_time DESC";
371 
372  $res = $this->db->queryF(
373  $query,
374  array('integer', 'integer'),
375  array($this->user_id, $a_folder_id)
376  );
377 
378  while ($row = $this->db->fetchAssoc($res)) {
379  $output[] = $this->fetchMailData($row);
380  }
381 
382  return $output;
383  }
foreach($_POST as $key=> $value) $res
$query
$row
fetchMailData($a_row)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNewDraftId()

ilMail::getNewDraftId (   $usrId,
  $folderId 
)
Parameters
int$usrId
int$folderId
Returns
int

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

601  {
602  $next_id = $this->db->nextId($this->table_mail);
603  $this->db->insert($this->table_mail, array(
604  'mail_id' => array('integer', $next_id),
605  'user_id' => array('integer', $usrId),
606  'folder_id' => array('integer', $folderId),
607  'sender_id' => array('integer', $usrId)
608  ));
609 
610  return $next_id;
611  }

◆ getNextMail()

ilMail::getNextMail (   $a_mail_id)
Parameters
int$a_mail_id
Returns
array

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

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

329  {
330  $this->db->setLimit(1);
331 
332  $res = $this->db->queryF(
333  "
334  SELECT b.* FROM {$this->table_mail} a
335  INNER JOIN {$this->table_mail} b ON b.folder_id = a.folder_id
336  AND b.user_id = a.user_id AND b.send_time < a.send_time
337  WHERE a.user_id = %s AND a.mail_id = %s ORDER BY b.send_time DESC",
338  array('integer', 'integer'),
339  array($this->user_id, $a_mail_id)
340  );
341 
342  $this->mail_data = $this->fetchMailData($this->db->fetchAssoc($res));
343 
344  return $this->mail_data;
345  }
foreach($_POST as $key=> $value) $res
fetchMailData($a_row)
+ Here is the call graph for this function:

◆ getPreviousMail()

ilMail::getPreviousMail (   $a_mail_id)
Parameters
int$a_mail_id
Returns
array

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

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

306  {
307  $this->db->setLimit(1);
308 
309  $res = $this->db->queryF(
310  "
311  SELECT b.* FROM {$this->table_mail} a
312  INNER JOIN {$this->table_mail} b ON b.folder_id = a.folder_id
313  AND b.user_id = a.user_id AND b.send_time > a.send_time
314  WHERE a.user_id = %s AND a.mail_id = %s ORDER BY b.send_time ASC",
315  array('integer', 'integer'),
316  array($this->user_id, $a_mail_id)
317  );
318 
319  $this->mail_data = $this->fetchMailData($this->db->fetchAssoc($res));
320 
321  return $this->mail_data;
322  }
foreach($_POST as $key=> $value) $res
fetchMailData($a_row)
+ Here is the call graph for this function:

◆ getSalutation()

static ilMail::getSalutation (   $a_usr_id,
ilLanguage  $a_language = null 
)
static
Parameters
int$a_usr_id
$a_languageilLanguage|null
Returns
string

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

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

Referenced by ilMailSummaryNotification\__construct(), ilTestManScoringParticipantNotification\buildBody(), ilSystemNotification\compose(), ilForumMailNotification\createMail(), ilChatroom\isOwnerOfPrivateRoom(), ilRegistrationMailNotification\send(), ilMailCronOrphanedMailsNotification\send(), ilDiskQuotaSummaryNotification\send(), ilSessionMembershipMailNotification\send(), ilBuddySystemNotification\send(), ilIndividualAssessmentPrimitiveInternalNotificator\send(), ilLearningSequenceMembershipMailNotification\send(), ilLMMailNotification\send(), ilExerciseMailNotification\send(), ilCourseMembershipMailNotification\send(), ilGroupMembershipMailNotification\send(), ilCalendarMailNotification\send(), ilTestMailNotification\sendAdvancedNotification(), ilTestMailNotification\sendSimpleNotification(), and ilObjSurveyGUI\sendUserResultsMail().

1734  {
1735  global $DIC;
1736 
1737  $lang = ($a_language instanceof ilLanguage) ? $a_language : $DIC->language();
1738  $lang->loadLanguageModule('mail');
1739 
1740  $gender = ilObjUser::_lookupGender($a_usr_id);
1741  $gender = $gender ? $gender : 'n';
1742  $name = ilObjUser::_lookupName($a_usr_id);
1743 
1744  if (!strlen($name['firstname'])) {
1745  return $lang->txt('mail_salutation_anonymous') . ',';
1746  }
1747 
1748  return
1749  $lang->txt('mail_salutation_' . $gender) . ' ' .
1750  ($name['title'] ? $name['title'] . ' ' : '') .
1751  ($name['firstname'] ? $name['firstname'] . ' ' : '') .
1752  $name['lastname'] . ',';
1753  }
static _lookupName($a_user_id)
lookup user name
global $DIC
Definition: saml.php:7
static _lookupGender($a_user_id)
Lookup gender.
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
Definition: langwiz.php:349
language handling
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSavedData()

ilMail::getSavedData ( )
Returns
array

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

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

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

1276  {
1277  $res = $this->db->queryF(
1278  "SELECT * FROM {$this->table_mail_saved} WHERE user_id = %s",
1279  array('integer'),
1280  array($this->user_id)
1281  );
1282 
1283  $this->mail_data = $this->fetchMailData($this->db->fetchAssoc($res));
1284 
1285  return $this->mail_data;
1286  }
foreach($_POST as $key=> $value) $res
fetchMailData($a_row)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSaveInSentbox()

ilMail::getSaveInSentbox ( )
Returns
bool

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

References $save_in_sentbox.

Referenced by sendMail().

245  {
246  return (bool) $this->save_in_sentbox;
247  }
$save_in_sentbox
+ 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 1716 of file class.ilMail.php.

References $DIC.

Referenced by ilMimeMail\Subject().

1717  {
1718  global $DIC;
1719 
1720  $subjectPrefix = $DIC->settings()->get('mail_subject_prefix');
1721  if (false === $subjectPrefix) {
1722  $subjectPrefix = self::MAIL_SUBJECT_PREFIX;
1723  }
1724 
1725  return $subjectPrefix;
1726  }
global $DIC
Definition: saml.php:7
+ Here is the caller graph for this function:

◆ getUserIds()

ilMail::getUserIds ( array  $recipients)
protected
Parameters
string[]$recipients
Returns
int[]

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

References parseAddresses().

Referenced by distributeMail().

1124  : array
1125  {
1126  $usrIds = array();
1127 
1128  $joinedRecipients = implode(',', array_filter(array_map('trim', $recipients)));
1129 
1130  $addresses = $this->parseAddresses($joinedRecipients);
1131  foreach ($addresses as $address) {
1132  $addressType = $this->mailAddressTypeFactory->getByPrefix($address);
1133  $usrIds = array_merge($usrIds, $addressType->resolve());
1134  }
1135 
1136  return array_unique($usrIds);
1137  }
parseAddresses($addresses)
Explode recipient string, allowed separators are &#39;,&#39; &#39;;&#39; &#39; &#39; Returns an array with recipient ilMailAd...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isSOAPEnabled()

ilMail::isSOAPEnabled ( )
Returns
bool

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

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

Referenced by saveInSentbox().

219  {
220  global $DIC;
221 
222  if (!extension_loaded('curl') || !$DIC->settings()->get('soap_user_administration')) {
223  return false;
224  }
225 
227  return false;
228  }
229 
230  return (bool) $this->soap_enabled;
231  }
global $DIC
Definition: saml.php:7
const CONTEXT_CRON
static getType()
Get context type.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isSystemMail()

ilMail::isSystemMail ( )
protected
Returns
bool

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

Referenced by sendMail().

161  {
162  return $this->user_id == ANONYMOUS_USER_ID;
163  }
+ Here is the caller graph for this function:

◆ markRead()

ilMail::markRead ( array  $a_mail_ids)
Parameters
array$a_mail_ids
Returns
bool

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

References $data, $in, and $query.

444  {
445  $data = array();
446  $data_types = array();
447 
448  $query = "UPDATE {$this->table_mail} SET m_status = %s WHERE user_id = %s ";
449  array_push($data_types, 'text', 'integer');
450  array_push($data, 'read', $this->user_id);
451 
452  if (count($a_mail_ids) > 0) {
453  $in = 'mail_id IN (';
454  $counter = 0;
455  foreach ($a_mail_ids as $a_mail_id) {
456  array_push($data, $a_mail_id);
457  array_push($data_types, 'integer');
458 
459  if ($counter > 0) {
460  $in .= ',';
461  }
462  $in .= '%s';
463  ++$counter;
464  }
465  $in .= ')';
466 
467  $query .= ' AND ' . $in;
468  }
469 
470  $this->db->manipulateF($query, $data_types, $data);
471 
472  return true;
473  }
$query
if(php_sapi_name() !='cli') $in
Definition: Utf8Test.php:37
$data
Definition: bench.php:6

◆ markUnread()

ilMail::markUnread ( array  $a_mail_ids)
Parameters
array$a_mail_ids
Returns
bool

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

References $data, $in, and $query.

480  {
481  $data = array();
482  $data_types = array();
483 
484  $query = "UPDATE {$this->table_mail} SET m_status = %s WHERE user_id = %s ";
485  array_push($data_types, 'text', 'integer');
486  array_push($data, 'unread', $this->user_id);
487 
488  if (count($a_mail_ids) > 0) {
489  $in = 'mail_id IN (';
490  $counter = 0;
491  foreach ($a_mail_ids as $a_mail_id) {
492  array_push($data, $a_mail_id);
493  array_push($data_types, 'integer');
494 
495  if ($counter > 0) {
496  $in .= ',';
497  }
498  $in .= '%s';
499  ++$counter;
500  }
501  $in .= ')';
502 
503  $query .= ' AND ' . $in;
504  }
505 
506  $this->db->manipulateF($query, $data_types, $data);
507 
508  return true;
509  }
$query
if(php_sapi_name() !='cli') $in
Definition: Utf8Test.php:37
$data
Definition: bench.php:6

◆ moveMailsToFolder()

ilMail::moveMailsToFolder ( array  $mailIds,
int  $folderId 
)
Parameters
int[]$mailIds
int$folderId
Returns
bool

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

References $in, $query, and $values.

516  : bool
517  {
518  $values = [];
519  $dataTypes = [];
520 
521  $mailIds = array_filter(array_map('intval', $mailIds));
522 
523  if (0 === count($mailIds)) {
524  return false;
525  }
526 
527  $query = "
528  UPDATE {$this->table_mail}
529  INNER JOIN mail_obj_data
530  ON mail_obj_data.obj_id = %s AND mail_obj_data.user_id = %s
531  SET {$this->table_mail}.folder_id = mail_obj_data.obj_id
532  WHERE {$this->table_mail}.user_id = %s
533  ";
534  array_push($dataTypes, 'integer', 'integer', 'integer');
535  array_push($values, $folderId, $this->user_id, $this->user_id);
536 
537  $in = 'mail_id IN (';
538  $counter = 0;
539  foreach ($mailIds as $mailId) {
540  array_push($values, $mailId);
541  array_push($dataTypes, 'integer');
542 
543  if ($counter > 0) {
544  $in .= ',';
545  }
546  $in .= '%s';
547  ++$counter;
548  }
549  $in .= ')';
550 
551  $query .= ' AND ' . $in;
552 
553  $affectedRows = $this->db->manipulateF($query, $dataTypes, $values);
554 
555  return $affectedRows > 0;
556  }
$values
$query
if(php_sapi_name() !='cli') $in
Definition: Utf8Test.php:37

◆ parseAddresses()

ilMail::parseAddresses (   $addresses)
protected

Explode recipient string, allowed separators are ',' ';' ' ' Returns an array with recipient ilMailAddress instances.

Parameters
string$addresses
Returns
ilMailAddress[] An array with objects of type ilMailAddress

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

References $parser, and ilLoggerFactory\getLogger().

Referenced by checkRecipients(), existsRecipient(), getCountRecipient(), getEmailRecipients(), and getUserIds().

1560  {
1561  if (strlen($addresses) > 0) {
1562  ilLoggerFactory::getLogger('mail')->debug(sprintf(
1563  "Started parsing of recipient string: %s",
1564  $addresses
1565  ));
1566  }
1567 
1568  $parser = $this->mailAddressParserFactory->getParser((string) $addresses);
1569  $parsedAddresses = $parser->parse();
1570 
1571  if (strlen($addresses) > 0) {
1572  ilLoggerFactory::getLogger('mail')->debug(sprintf(
1573  "Parsed addresses: %s",
1574  implode(',', array_map(function (ilMailAddress $address) {
1575  return (string) $address;
1576  }, $parsedAddresses))
1577  ));
1578  }
1579 
1580  return $parsedAddresses;
1581  }
$parser
Definition: BPMN2Parser.php:23
static getLogger($a_component_id)
Get component logger.
Class ilMailAddress.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readMailObjectReferenceId()

ilMail::readMailObjectReferenceId ( )
protected

Read and set the mail object ref id (administration node)

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

References ilMailGlobalServices\getMailObjectRefId().

Referenced by __construct().

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

◆ replacePlaceholders()

ilMail::replacePlaceholders (   $a_message,
  $a_user_id = 0,
  $replace_empty = true 
)
protected
Parameters
string$a_message
int$a_user_id
boolean$replace_empty
Returns
string

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

References $context, $user, ilLoggerFactory\getLogger(), and ilMailTemplateContextService\getTemplateContextById().

Referenced by distributeMail(), sendInternalMail(), and sendMail().

784  {
785  try {
786  if ($this->contextId) {
788  } else {
790  }
791 
792  $user = $a_user_id > 0 ? self::getCachedUserInstance($a_user_id) : null;
793 
794  $processor = new ilMailTemplatePlaceholderResolver($context, $a_message);
795  $a_message = $processor->resolve($user, $this->contextParameters, $replace_empty);
796  } catch (Exception $e) {
797  ilLoggerFactory::getLogger('mail')->error(__METHOD__ . ' has been called with invalid context.');
798  }
799 
800  return $a_message;
801  }
$context
Definition: webdav.php:25
$user
Definition: migrateto20.php:57
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveAttachments()

ilMail::saveAttachments (   $a_attachments)
Parameters
array$a_attachmentsAn array of attachments
Returns
bool

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

1539  {
1540  $this->db->update(
1541  $this->table_mail_saved,
1542  array(
1543  'attachments' => array('clob', serialize($a_attachments))
1544  ),
1545  array(
1546  'user_id' => array('integer', $this->user_id)
1547  )
1548  );
1549 
1550  return true;
1551  }

◆ saveInSentbox()

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

Stores a message in the sent bod of the current user.

Parameters
array$a_attachment
string$a_rcp_to
string$a_rcp_cc
string$a_rcp_bcc
array$a_type
string$a_m_subject
string$a_m_message
Returns
int mail id

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

References $_COOKIE, $a_type, $GLOBALS, $user_id, isSOAPEnabled(), and sendInternalMail().

Referenced by sendMail().

1440  {
1441  return $this->sendInternalMail(
1442  $this->mailbox->getSentFolder(),
1444  $a_attachment,
1445  $a_rcp_to,
1446  $a_rcp_cc,
1447  $a_rcp_bcc,
1448  'read',
1449  $a_type,
1450  0,
1451  $a_m_subject,
1452  $a_m_message,
1454  0
1455  );
1456  }
$a_type
Definition: workflow.php:92
sendInternalMail( $a_folder_id, $a_sender_id, $a_attachments, $a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_status, $a_m_type, $a_m_email, $a_m_subject, $a_m_message, $a_user_id=0, $a_use_placeholders=0, $a_tpl_context_id=null, $a_tpl_context_params=array())
save mail in folder private
+ 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,
  $a_tpl_context_id = null,
  $a_tpl_ctx_params = array() 
)

save post data in table public

Parameters
int$a_user_id
array$a_attachments
string$a_rcp_to
string$a_rcp_cc
string$a_rcp_bcc
array$a_m_type
int$a_m_email
string$a_m_subject
string$a_m_message
int$a_use_placeholders
string | null$a_tpl_context_id
array | null$a_tpl_ctx_params
Returns
bool

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

References getSavedData().

Referenced by ilObjUserFolderGUI\mailObject().

1221  {
1222  if (!$a_attachments) {
1223  $a_attachments = null;
1224  }
1225  if (!$a_rcp_to) {
1226  $a_rcp_to = null;
1227  }
1228  if (!$a_rcp_cc) {
1229  $a_rcp_cc = null;
1230  }
1231  if (!$a_rcp_bcc) {
1232  $a_rcp_bcc = null;
1233  }
1234  if (!$a_m_type) {
1235  $a_m_type = null;
1236  }
1237  if (!$a_m_email) {
1238  $a_m_email = null;
1239  }
1240  if (!$a_m_message) {
1241  $a_m_message = null;
1242  }
1243  if (!$a_use_placeholders) {
1244  $a_use_placeholders = '0';
1245  }
1246 
1247  $this->db->replace(
1248  $this->table_mail_saved,
1249  array(
1250  'user_id' => array('integer', $this->user_id)
1251  ),
1252  array(
1253  'attachments' => array('clob', serialize($a_attachments)),
1254  'rcp_to' => array('clob', $a_rcp_to),
1255  'rcp_cc' => array('clob', $a_rcp_cc),
1256  'rcp_bcc' => array('clob', $a_rcp_bcc),
1257  'm_type' => array('text', serialize($a_m_type)),
1258  'm_email' => array('integer', $a_m_email),
1259  'm_subject' => array('text', $a_m_subject),
1260  'm_message' => array('clob', $a_m_message),
1261  'use_placeholders' => array('integer', $a_use_placeholders),
1262  'tpl_ctx_id' => array('text', $a_tpl_context_id),
1263  'tpl_ctx_params' => array('blob', json_encode((array) $a_tpl_ctx_params))
1264  )
1265  );
1266 
1267  $this->getSavedData();
1268 
1269  return true;
1270  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendInternalMail()

ilMail::sendInternalMail (   $a_folder_id,
  $a_sender_id,
  $a_attachments,
  $a_rcp_to,
  $a_rcp_cc,
  $a_rcp_bcc,
  $a_status,
  $a_m_type,
  $a_m_email,
  $a_m_subject,
  $a_m_message,
  $a_user_id = 0,
  $a_use_placeholders = 0,
  $a_tpl_context_id = null,
  $a_tpl_context_params = array() 
)
private

save mail in folder private

Parameters
integer$a_folder_id
integer$a_sender_id
array$a_attachments
string$a_rcp_to
string$a_rcp_cc
string$a_rcp_bcc
string$a_status
array$a_m_type
integer$a_m_email
string$a_m_subject
string$a_m_message
integer$a_user_id
integer$a_use_placeholders
string | null$a_tpl_context_id
array | null$a_tpl_context_params
Returns
integer mail_id

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

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

Referenced by distributeMail(), and saveInSentbox().

690  {
691  $a_user_id = $a_user_id ? $a_user_id : $this->user_id;
692 
693  if ($a_use_placeholders) {
694  $a_m_message = $this->replacePlaceholders($a_m_message, $a_user_id);
695  }
696  $a_m_message = $this->formatLinebreakMessage($a_m_message);
697 
698  if (!$a_user_id) {
699  $a_user_id = '0';
700  }
701  if (!$a_folder_id) {
702  $a_folder_id = '0';
703  }
704  if (!$a_sender_id) {
705  $a_sender_id = null;
706  }
707  if (!$a_attachments) {
708  $a_attachments = null;
709  }
710  if (!$a_rcp_to) {
711  $a_rcp_to = null;
712  }
713  if (!$a_rcp_cc) {
714  $a_rcp_cc = null;
715  }
716  if (!$a_rcp_bcc) {
717  $a_rcp_bcc = null;
718  }
719  if (!$a_status) {
720  $a_status = null;
721  }
722  if (!$a_m_type) {
723  $a_m_type = null;
724  }
725  if (!$a_m_email) {
726  $a_m_email = null;
727  }
728  if (!$a_m_subject) {
729  $a_m_subject = null;
730  }
731  if (!$a_m_message) {
732  $a_m_message = null;
733  }
734 
735  $nextId = $this->db->nextId($this->table_mail);
736  $this->db->insert($this->table_mail, array(
737  'mail_id' => array('integer', $nextId),
738  'user_id' => array('integer', $a_user_id),
739  'folder_id' => array('integer', $a_folder_id),
740  'sender_id' => array('integer', $a_sender_id),
741  'attachments' => array('clob', serialize($a_attachments)),
742  'send_time' => array('timestamp', date('Y-m-d H:i:s', time())),
743  'rcp_to' => array('clob', $a_rcp_to),
744  'rcp_cc' => array('clob', $a_rcp_cc),
745  'rcp_bcc' => array('clob', $a_rcp_bcc),
746  'm_status' => array('text', $a_status),
747  'm_type' => array('text', serialize($a_m_type)),
748  'm_email' => array('integer', $a_m_email),
749  'm_subject' => array('text', $a_m_subject),
750  'm_message' => array('clob', $a_m_message),
751  'tpl_ctx_id' => array('text', $a_tpl_context_id),
752  'tpl_ctx_params' => array('blob', @json_encode((array) $a_tpl_context_params))
753  ));
754 
755  $raiseEvent = (int) $a_user_id !== (int) $this->mailbox->getUserId();
756  if (!$raiseEvent) {
757  $raiseEvent = (int) $a_folder_id !== (int) $this->mailbox->getSentFolder();
758  }
759 
760  if ($raiseEvent) {
761  $this->eventHandler->raise('Services/Mail', 'sentInternalMail', [
762  'id' => (int) $nextId,
763  'subject' => (string) $a_m_subject,
764  'body' => (string) $a_m_message,
765  'from_usr_id' => (int) $a_sender_id,
766  'to_usr_id' => (int) $a_user_id,
767  'rcp_to' => (string) $a_rcp_to,
768  'rcp_cc' => (string) $a_rcp_cc,
769  'rcp_bcc' => (string) $a_rcp_bcc,
770  'type' => (array) $a_m_type,
771  ]);
772  }
773 
774  return $nextId;
775  }
formatLinebreakMessage($a_message)
replacePlaceholders($a_message, $a_user_id=0, $replace_empty=true)
+ 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 
)

Should be used to send notifcations over the internal or external mail channel.

Parameters
string$a_rcp_to
string$a_rcp_cc
string$a_rcp_bc
string$a_m_subject
string$a_m_message
array$a_attachment
array$a_type(normal and/or system and/or email)
bool | int$a_use_placeholders
Returns
[]

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

References $a_type, $DIC, $errors, appendInstallationSignature(), checkMail(), deleteMails(), distributeMail(), formatLinebreakMessage(), getCountRecipients(), getEmailRecipients(), ilLoggerFactory\getLogger(), getSaveInSentbox(), isSystemMail(), replacePlaceholders(), saveInSentbox(), and validateRecipients().

1300  : array
1301  {
1302  global $DIC;
1303 
1304  ilLoggerFactory::getLogger('mail')->debug(
1305  "New mail system task:" .
1306  " To: " . $a_rcp_to .
1307  " | CC: " . $a_rcp_cc .
1308  " | BCC: " . $a_rcp_bc .
1309  " | Subject: " . $a_m_subject
1310  );
1311 
1312  if (in_array('system', $a_type)) {
1313  $a_type = array('system');
1314  }
1315 
1316  if ($a_attachment && !$this->mfile->checkFilesExist($a_attachment)) {
1317  return [new \ilMailError('mail_attachment_file_not_exist', [$a_attachment])];
1318  }
1319 
1320  $errors = $this->checkMail((string) $a_rcp_to, (string) $a_rcp_cc, (string) $a_rcp_bc, (string) $a_m_subject);
1321  if (count($errors) > 0) {
1322  return $errors;
1323  }
1324 
1325  $errors = $this->validateRecipients((string) $a_rcp_to, (string) $a_rcp_cc, (string) $a_rcp_bc);
1326  if (count($errors) > 0) {
1327  return $errors;
1328  }
1329 
1330  $rcp_to = $a_rcp_to;
1331  $rcp_cc = $a_rcp_cc;
1332  $rcp_bc = $a_rcp_bc;
1333 
1334  if (null === $rcp_cc) {
1335  $rcp_cc = '';
1336  }
1337 
1338  if (null === $rcp_bc) {
1339  $rcp_bc = '';
1340  }
1341 
1342  $numberOfExternalAddresses = $this->getCountRecipients($rcp_to, $rcp_cc, $rcp_bc, true);
1343 
1344  if (
1345  $numberOfExternalAddresses > 0 &&
1346  !$this->isSystemMail() &&
1347  !$DIC->rbac()->system()->checkAccessOfUser($this->user_id, 'smtp_mail', $this->mail_obj_ref_id)
1348  ) {
1349  return [new \ilMailError('mail_no_permissions_write_smtp')];
1350  }
1351 
1352  if ($this->appendInstallationSignature()) {
1353  $a_m_message .= self::_getInstallationSignature();
1354  }
1355 
1356  $sent_id = $this->saveInSentbox($a_attachment, $a_rcp_to, $a_rcp_cc, $a_rcp_bc, $a_type, $a_m_subject, $a_m_message);
1357 
1358  if ($a_attachment) {
1359  $this->mfile->assignAttachmentsToDirectory($sent_id, $sent_id);
1360  $this->mfile->saveFiles($sent_id, $a_attachment);
1361  }
1362 
1363  if ($numberOfExternalAddresses > 0) {
1364  $externalMailRecipientsTo = $this->getEmailRecipients($rcp_to);
1365  $externalMailRecipientsCc = $this->getEmailRecipients($rcp_cc);
1366  $externalMailRecipientsBcc = $this->getEmailRecipients($rcp_bc);
1367 
1368  ilLoggerFactory::getLogger('mail')->debug(
1369  "Parsed external email addresses from given recipients:" .
1370  " To: " . $externalMailRecipientsTo .
1371  " | CC: " . $externalMailRecipientsCc .
1372  " | BCC: " . $externalMailRecipientsBcc .
1373  " | Subject: " . $a_m_subject
1374  );
1375 
1376  $this->sendMimeMail(
1377  $externalMailRecipientsTo,
1378  $externalMailRecipientsCc,
1379  $externalMailRecipientsBcc,
1380  $a_m_subject,
1381  $this->formatLinebreakMessage($a_use_placeholders ? $this->replacePlaceholders($a_m_message, 0, false) : $a_m_message),
1382  $a_attachment,
1383  0
1384  );
1385  } else {
1386  ilLoggerFactory::getLogger('mail')->debug('No external email addresses given in recipient string');
1387  }
1388 
1389  if (in_array('system', $a_type) && !$this->distributeMail($rcp_to, $rcp_cc, $rcp_bc, $a_m_subject, $a_m_message, $a_attachment, $sent_id, $a_type, 'system', $a_use_placeholders)) {
1390  return [new \ilMailError('mail_send_error')];
1391  }
1392 
1393  if (in_array('normal', $a_type) && !$this->distributeMail($rcp_to, $rcp_cc, $rcp_bc, $a_m_subject, $a_m_message, $a_attachment, $sent_id, $a_type, 'normal', $a_use_placeholders)) {
1394  return [new \ilMailError('mail_send_error')];
1395  }
1396 
1397  if (!$this->getSaveInSentbox()) {
1398  $this->deleteMails([$sent_id]);
1399  }
1400 
1401  return [];
1402  }
getEmailRecipients(string $recipients)
getCountRecipients(string $toRecipients, string $ccRecipients, string $bccRecipients, $onlyExternalAddresses=true)
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)
global $DIC
Definition: saml.php:7
checkMail(string $to, string $cc, string $bcc, string $subject)
$a_type
Definition: workflow.php:92
isSystemMail()
getSaveInSentbox()
appendInstallationSignature($a_flag=null)
Setter/Getter for appending the installation signarue.
validateRecipients(string $to, string $cc, string $bcc)
formatLinebreakMessage($a_message)
replacePlaceholders($a_message, $a_user_id=0, $replace_empty=true)
$errors
Definition: index.php:6
deleteMails(array $mailIds)
static getLogger($a_component_id)
Get component logger.
saveInSentbox($a_attachment, $a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_type, $a_m_subject, $a_m_message)
Stores a message in the sent bod of the current user.
+ Here is the call graph for this function:

◆ setSaveInSentbox()

ilMail::setSaveInSentbox (   $a_save_in_sentbox)
Parameters
bool$a_save_in_sentbox

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

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

237  {
238  $this->save_in_sentbox = (bool) $a_save_in_sentbox;
239  }
+ 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,
  $a_tpl_context_id = null,
  $a_tpl_context_params = array() 
)

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

627  {
628  $this->db->update(
629  $this->table_mail,
630  array(
631  'folder_id' => array('integer', $a_folder_id),
632  'attachments' => array('clob', serialize($a_attachments)),
633  'send_time' => array('timestamp', date('Y-m-d H:i:s', time())),
634  'rcp_to' => array('clob', $a_rcp_to),
635  'rcp_cc' => array('clob', $a_rcp_cc),
636  'rcp_bcc' => array('clob', $a_rcp_bcc),
637  'm_status' => array('text', 'read'),
638  'm_type' => array('text', serialize($a_m_type)),
639  'm_email' => array('integer', $a_m_email),
640  'm_subject' => array('text', $a_m_subject),
641  'm_message' => array('clob', $a_m_message),
642  'use_placeholders' => array('integer', $a_use_placeholders),
643  'tpl_ctx_id' => array('text', $a_tpl_context_id),
644  'tpl_ctx_params' => array('blob', @json_encode((array) $a_tpl_context_params))
645  ),
646  array(
647  'mail_id' => array('integer', $a_draft_id)
648  )
649  );
650 
651  return $a_draft_id;
652  }

◆ validateRecipients()

ilMail::validateRecipients ( string  $to,
string  $cc,
string  $bcc 
)
Parameters
string$to
string$cc
string$bcc
Returns
[] An array of errors determined on validation

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

References $errors, and checkRecipients().

Referenced by sendMail().

1410  : array
1411  {
1412  try {
1413  $errors = array();
1414  $errors = array_merge($errors, $this->checkRecipients($to));
1415  $errors = array_merge($errors, $this->checkRecipients($cc));
1416  $errors = array_merge($errors, $this->checkRecipients($bcc));
1417 
1418  if (count($errors) > 0) {
1419  return array_merge([new \ilMailError('mail_following_rcp_not_valid')], $errors);
1420  }
1421  } catch (\ilMailException $e) {
1422  return [new \ilMailError('mail_generic_rcp_error', [$e->getMessage()])];
1423  }
1424 
1425  return [];
1426  }
Class ilMailError.
Class ilMailException.
checkRecipients(string $recipients)
Check if recipients are valid.
$errors
Definition: index.php:6
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ withContextId()

ilMail::withContextId ( string  $contextId)
Parameters
string$contextId
Returns
ilMail

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

References $contextId.

135  : self
136  {
137  $clone = clone $this;
138 
139  $clone->contextId = $contextId;
140 
141  return $clone;
142  }

◆ withContextParameters()

ilMail::withContextParameters ( array  $parameters)
Parameters
array$parameters
Returns
ilMail

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

148  : self
149  {
150  $clone = clone $this;
151 
152  $clone->contextParameters = $parameters;
153 
154  return $clone;
155  }

Field Documentation

◆ $appendInstallationSignature

ilMail::$appendInstallationSignature = false
protected

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

Referenced by appendInstallationSignature().

◆ $contextId

ilMail::$contextId = null
protected

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

Referenced by withContextId().

◆ $contextParameters

ilMail::$contextParameters = []
protected

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

◆ $db

ilMail::$db
protected

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

◆ $eventHandler

ilMail::$eventHandler
private

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

Referenced by __construct().

◆ $lng

ilMail::$lng
protected

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

◆ $mail_data

ilMail::$mail_data = array()
protected

◆ $mail_obj_ref_id

ilMail::$mail_obj_ref_id
protected

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

Referenced by getMailObjectReferenceId().

◆ $mail_options

ilMail::$mail_options
protected

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

◆ $mailAddressParserFactory

ilMail::$mailAddressParserFactory
private

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

Referenced by __construct().

◆ $mailAddressTypeFactory

ilMail::$mailAddressTypeFactory
private

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

Referenced by __construct().

◆ $mailbox

ilMail::$mailbox
protected

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

◆ $mfile

ilMail::$mfile
protected

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

◆ $properties

ilMail::$properties = array()
protected

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

◆ $save_in_sentbox

ilMail::$save_in_sentbox
protected

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

Referenced by getSaveInSentbox().

◆ $soap_enabled

ilMail::$soap_enabled = true
protected

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

Referenced by isSOAPEnabled().

◆ $table_mail

ilMail::$table_mail
protected

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

◆ $table_mail_saved

ilMail::$table_mail_saved
protected

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

◆ $user_id

ilMail::$user_id

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

Referenced by saveInSentbox(), and sendInternalMail().

◆ $userInstances

ilMail::$userInstances = array()
staticprotected

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

◆ ILIAS_HOST

const ilMail::ILIAS_HOST = 'ilias'

◆ MAIL_SUBJECT_PREFIX

const ilMail::MAIL_SUBJECT_PREFIX = '[ILIAS]'

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

Referenced by ilObjMailGUI\populateExternalSettingsForm().


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