protected function __distributeMails($password, $a_language = null)
 {
     global $ilSetting;
     include_once './Services/Language/classes/class.ilLanguage.php';
     include_once './Services/User/classes/class.ilObjUser.php';
     include_once "Services/Mail/classes/class.ilFormatMail.php";
     include_once './Services/Registration/classes/class.ilRegistrationMailNotification.php';
     // Always send mail to approvers
     if ($this->registration_settings->getRegistrationType() == IL_REG_APPROVE && !$this->code_was_used) {
         $mail = new ilRegistrationMailNotification();
         $mail->setType(ilRegistrationMailNotification::TYPE_NOTIFICATION_CONFIRMATION);
         $mail->setRecipients($this->registration_settings->getApproveRecipients());
         $mail->setAdditionalInformation(array('usr' => $this->userObj));
         $mail->send();
     } else {
         $mail = new ilRegistrationMailNotification();
         $mail->setType(ilRegistrationMailNotification::TYPE_NOTIFICATION_APPROVERS);
         $mail->setRecipients($this->registration_settings->getApproveRecipients());
         $mail->setAdditionalInformation(array('usr' => $this->userObj));
         $mail->send();
     }
     // Send mail to new user
     // Registration with confirmation link ist enabled
     if ($this->registration_settings->getRegistrationType() == IL_REG_ACTIVATION && !$this->code_was_used) {
         include_once './Services/Registration/classes/class.ilRegistrationMimeMailNotification.php';
         $mail = new ilRegistrationMimeMailNotification();
         $mail->setType(ilRegistrationMimeMailNotification::TYPE_NOTIFICATION_ACTIVATION);
         $mail->setRecipients(array($this->userObj));
         $mail->setAdditionalInformation(array('usr' => $this->userObj, 'hash_lifetime' => $this->registration_settings->getRegistrationHashLifetime()));
         $mail->send();
     } else {
         // try individual account mail in user administration
         include_once "Services/Mail/classes/class.ilAccountMail.php";
         include_once './Services/User/classes/class.ilObjUserFolder.php';
         $amail = ilObjUserFolder::_lookupNewAccountMail($a_language);
         if (trim($amail["body"]) == "" || trim($amail["subject"]) == "") {
             $amail = ilObjUserFolder::_lookupNewAccountMail($GLOBALS["lng"]->getDefaultLanguage());
         }
         if (trim($amail["body"]) != "" && trim($amail["subject"]) != "") {
             $acc_mail = new ilAccountMail();
             $acc_mail->setUser($this->userObj);
             if ($this->registration_settings->passwordGenerationEnabled()) {
                 $acc_mail->setUserPassword($password);
             }
             if ($amail["att_file"]) {
                 include_once "Services/User/classes/class.ilFSStorageUserFolder.php";
                 $fs = new ilFSStorageUserFolder(USER_FOLDER_ID);
                 $fs->create();
                 $path = $fs->getAbsolutePath() . "/";
                 $acc_mail->addAttachment($path . "/" . $amail["lang"], $amail["att_file"]);
             }
             $acc_mail->send();
         } else {
             include_once "Services/Mail/classes/class.ilMimeMail.php";
             $mmail = new ilMimeMail();
             $mmail->autoCheck(false);
             $mmail->From($ilSetting->get("admin_email"));
             $mmail->To($this->userObj->getEmail());
             // mail subject
             $subject = $this->lng->txt("reg_mail_subject");
             // mail body
             $body = $this->lng->txt("reg_mail_body_salutation") . " " . $this->userObj->getFullname() . ",\n\n" . $this->lng->txt("reg_mail_body_text1") . "\n\n" . $this->lng->txt("reg_mail_body_text2") . "\n" . ILIAS_HTTP_PATH . "/login.php?client_id=" . CLIENT_ID . "\n";
             $body .= $this->lng->txt("login") . ": " . $this->userObj->getLogin() . "\n";
             if ($this->registration_settings->passwordGenerationEnabled()) {
                 $body .= $this->lng->txt("passwd") . ": " . $password . "\n";
             }
             $body .= "\n";
             // Info about necessary approvement
             if ($this->registration_settings->getRegistrationType() == IL_REG_APPROVE && !$this->code_was_used) {
                 $body .= $this->lng->txt('reg_mail_body_pwd_generation') . "\n\n";
             }
             $body .= $this->lng->txt("reg_mail_body_text3") . "\n\r";
             $body .= $this->userObj->getProfileAsString($this->lng);
             $mmail->Subject($subject);
             $mmail->Body($body);
             $mmail->Send();
         }
     }
 }
 function _deleteAccountMailAttachment($a_lang)
 {
     global $ilDB;
     include_once "Services/User/classes/class.ilFSStorageUserFolder.php";
     $fs = new ilFSStorageUserFolder($this->getId());
     $path = $fs->getAbsolutePath() . "/";
     @unlink($path . $a_lang);
     $ilDB->update('mail_template', array('att_file' => array('text', '')), array('lang' => array('text', $a_lang), 'type' => array('text', 'nacc')));
 }
 /**
  * send account mail
  */
 function sendAccountMail()
 {
     if ($_POST["send_mail"] != "" || $this->isSendMail() && $this->userObj->getEmail() != "") {
         $this->acc_mail->setUser($this->userObj);
         $amail = $this->readAccountMailFromCache($this->userObj->getLanguage());
         if ($amail["att_file"]) {
             include_once "Services/User/classes/class.ilFSStorageUserFolder.php";
             $fs = new ilFSStorageUserFolder(USER_FOLDER_ID);
             $fs->create();
             $path = $fs->getAbsolutePath() . "/";
             $this->acc_mail->addAttachment($path . "/" . $amail["lang"], $amail["att_file"]);
         }
         $this->acc_mail->send();
     }
 }