Esempio n. 1
0
 /**
  *
  * @param CAccount $oAccount
  * @param string $sSubject
  * @param string $sEventName
  * @param string $sDate
  * @param string $sCalendarName
  * @param string $sEventText
  * @param string $sCalendarColor
  *
  * @return bool
  */
 private function sendMessage($oAccount, $sSubject, $sEventName, $sDate, $sCalendarName, $sEventText, $sCalendarColor)
 {
     $oMessage = $this->createMessage($oAccount, $sSubject, $this->createBodyHtml($oAccount, $sEventName, $sDate, $sCalendarName, $sEventText, $sCalendarColor), $this->createBodyText($oAccount, $sEventName, $sDate, $sCalendarName, $sEventText));
     try {
         return $this->oApiMailManager->sendMessage($oAccount, $oMessage);
     } catch (Exception $oException) {
         CApi::Log('MessageSend Exception', ELogLevel::Error, 'cron-');
         CApi::LogException($oException, ELogLevel::Error, 'cron-');
     }
     return false;
 }
Esempio n. 2
0
 /**
  * @return array
  */
 public function AjaxAccountResetPassword()
 {
     $mResult = false;
     $oAccount = $this->getDefaultAccountFromParam();
     $sUrlHash = $this->getParamValue('UrlHash', '');
     $oTenant = null;
     if ($oAccount->Domain->IdTenant > 0) {
         $oTenant = $this->oApiTenants->getTenantById($oAccount->Domain->IdTenant);
     } else {
         $oTenant = $this->oApiTenants->getDefaultGlobalTenant();
     }
     if ($oTenant) {
         $oNotificationAccount = $this->oApiUsers->GetAccountByEmail($oTenant->InviteNotificationEmailAccount);
         if ($oNotificationAccount) {
             $sPasswordResetUrl = rtrim(\api_Utils::GetAppUrl(), '/');
             $sPasswordResetHash = \md5(\time() . \rand(1000, 9999) . \CApi::$sSalt);
             $oAccount->User->PasswordResetHash = $sPasswordResetHash;
             $this->oApiUsers->updateAccount($oAccount);
             $sSubject = \CApi::ClientI18N('ACCOUNT_PASSWORD_RESET/SUBJECT', $oAccount, array('SITE_NAME' => $oAccount->Domain->SiteName));
             $sBody = \CApi::ClientI18N('ACCOUNT_PASSWORD_RESET/BODY', $oAccount, array('SITE_NAME' => $oAccount->Domain->SiteName, 'PASSWORD_RESET_URL' => $sPasswordResetUrl . '/?reset-pass='******'#' . $sUrlHash, 'EMAIL' => $oAccount->Email));
             $oMessage = \MailSo\Mime\Message::NewInstance();
             $oMessage->RegenerateMessageId();
             $oMessage->DoesNotCreateEmptyTextPart();
             $sXMailer = \CApi::GetConf('webmail.xmailer-value', '');
             if (0 < strlen($sXMailer)) {
                 $oMessage->SetXMailer($sXMailer);
             }
             $oMessage->SetFrom(\MailSo\Mime\Email::NewInstance($oTenant->InviteNotificationEmailAccount))->SetSubject($sSubject)->AddText($sBody, true);
             $oToEmails = \MailSo\Mime\EmailCollection::NewInstance($oAccount->Email);
             if ($oToEmails && $oToEmails->Count()) {
                 $oMessage->SetTo($oToEmails);
             }
             if ($oMessage) {
                 try {
                     $mResult = $this->oApiMail->sendMessage($oNotificationAccount, $oMessage);
                 } catch (\CApiManagerException $oException) {
                     throw $oException;
                 }
             }
         }
     }
     return $this->DefaultResponse($oAccount, __FUNCTION__, $mResult);
 }