Пример #1
0
 /**
  * @param int $iIndex
  * @param string $sParentCharset = \MailSo\Base\Enumerations\Charset::ISO_8859_1
  *
  * @return \MailSo\Mime\EmailCollection|null
  */
 public function GetFetchEnvelopeEmailCollection($iIndex, $sParentCharset = \MailSo\Base\Enumerations\Charset::ISO_8859_1)
 {
     $oResult = null;
     $aEmails = $this->GetFetchEnvelopeValue($iIndex, null);
     if (is_array($aEmails) && 0 < count($aEmails)) {
         $oResult = \MailSo\Mime\EmailCollection::NewInstance();
         foreach ($aEmails as $aEmailItem) {
             if (is_array($aEmailItem) && 4 === count($aEmailItem)) {
                 $sDisplayName = \MailSo\Base\Utils::DecodeHeaderValue(self::findEnvelopeIndex($aEmailItem, 0, ''), $sParentCharset);
                 $sRemark = \MailSo\Base\Utils::DecodeHeaderValue(self::findEnvelopeIndex($aEmailItem, 1, ''), $sParentCharset);
                 $sLocalPart = self::findEnvelopeIndex($aEmailItem, 2, '');
                 $sDomainPart = self::findEnvelopeIndex($aEmailItem, 3, '');
                 if (0 < strlen($sLocalPart) && 0 < strlen($sDomainPart)) {
                     $oResult->Add(\MailSo\Mime\Email::NewInstance($sLocalPart . '@' . $sDomainPart, $sDisplayName, $sRemark));
                 }
             }
         }
     }
     return $oResult;
 }
Пример #2
0
 /**
  * @param CHelpdeskThread $oThread Helpdesk thread object
  */
 public function notifyOutdated($oThread)
 {
     if ($oThread) {
         $oFromAccount = null;
         $aData = $this->getHelpdeskMainSettings($oThread->IdTenant);
         if (!empty($aData['AdminEmailAccount'])) {
             $oApiUsers = $this->_getApiUsers();
             if ($oApiUsers) {
                 $oFromAccount = $oApiUsers->getAccountByEmail($aData['AdminEmailAccount']);
             }
         }
         $sSiteName = isset($aData['SiteName']) ? $aData['SiteName'] : '';
         $oHelpdeskThreadOwnerUser = $this->getUserById($oThread->IdTenant, $oThread->IdOwner);
         // mail notifications
         if ($oFromAccount && $oHelpdeskThreadOwnerUser) {
             $oApiMail = $this->_getApiMail();
             if ($oApiMail) {
                 $oHelpdeskPostOwnerUser = $this->getUserById($oThread->IdTenant, $oThread->IdOwner);
                 $sEmail = $oHelpdeskThreadOwnerUser->resultEmail();
                 if (!empty($sEmail)) {
                     $oHelpdeskSenderEmail = \MailSo\Mime\Email::NewInstance($oFromAccount->Email, $sSiteName);
                     $oThreadOwnerEmail = \MailSo\Mime\Email::NewInstance($sEmail, $oHelpdeskThreadOwnerUser->Name);
                     if ($oHelpdeskThreadOwnerUser->IdHelpdeskUser === $oThread->IdOwner) {
                         $oUserMessage = $this->_buildPostMail(PSEVEN_APP_ROOT_PATH . 'templates/helpdesk/user.post.notification.html', $oHelpdeskSenderEmail->ToString(), $oThreadOwnerEmail->ToString(), 'New Post', '', '', $oHelpdeskThreadOwnerUser, $oHelpdeskPostOwnerUser, $oThread, null, $sSiteName);
                         if ($oUserMessage) {
                             $oApiMail->sendMessage($oFromAccount, $oUserMessage);
                         }
                     }
                 }
             }
         }
     }
 }
Пример #3
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);
 }
Пример #4
0
 /**
  * @param \RainLoop\Model\Account $oAccount
  *
  * @return \MailSo\Mime\Message
  */
 private function buildReadReceiptMessage($oAccount)
 {
     $sReadReceipt = $this->GetActionParam('ReadReceipt', '');
     $sSubject = $this->GetActionParam('Subject', '');
     $sText = $this->GetActionParam('Text', '');
     $oIdentity = $this->GetAccountIdentity($oAccount);
     if (empty($sReadReceipt) || empty($sSubject) || empty($sText) || !$oIdentity) {
         throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::UnknownError);
     }
     $oMessage = \MailSo\Mime\Message::NewInstance();
     $oMessage->RegenerateMessageId();
     $oMessage->SetXMailer('RainLoop/' . APP_VERSION);
     $oMessage->SetFrom(\MailSo\Mime\Email::NewInstance($oIdentity->Email(), $oIdentity->Name()));
     $sReplyTo = $oIdentity->ReplyTo();
     if (!empty($sReplyTo)) {
         $oReplyTo = \MailSo\Mime\EmailCollection::NewInstance($sReplyTo);
         if ($oReplyTo && $oReplyTo->Count()) {
             $oMessage->SetReplyTo($oReplyTo);
         }
     }
     $oMessage->SetSubject($sSubject);
     $oToEmails = \MailSo\Mime\EmailCollection::NewInstance($sReadReceipt);
     if ($oToEmails && $oToEmails->Count()) {
         $oMessage->SetTo($oToEmails);
     }
     $this->Plugins()->RunHook('filter.read-receipt-message-plain', array($oAccount, &$oMessage, &$sText));
     $oMessage->AddText($sText, false);
     $this->Plugins()->RunHook('filter.build-read-receipt-message', array(&$oMessage, $oAccount));
     return $oMessage;
 }
Пример #5
0
 /**
  * @param CAccount $oAccount
  * @param string $sSubject
  * @param string $mHtml = null
  * @param string $mText = null
  *
  * @return \MailSo\Mime\Message
  */
 private function createMessage($oAccount, $sSubject, $mHtml = null, $mText = null)
 {
     $oMessage = \MailSo\Mime\Message::NewInstance();
     $oMessage->RegenerateMessageId();
     $sXMailer = CApi::GetConf('webmail.xmailer-value', '');
     if (0 < strlen($sXMailer)) {
         $oMessage->SetXMailer($sXMailer);
     }
     $oMessage->SetFrom(\MailSo\Mime\Email::NewInstance($oAccount->Email))->SetSubject($sSubject);
     $oToEmails = \MailSo\Mime\EmailCollection::NewInstance($oAccount->Email);
     if ($oToEmails && $oToEmails->Count()) {
         $oMessage->SetTo($oToEmails);
     }
     if ($mHtml !== null) {
         $oMessage->AddText($mHtml, true);
     }
     if ($mText !== null) {
         $oMessage->AddText($mText, false);
     }
     return $oMessage;
 }
 /**
  * @expectedException \MailSo\Base\Exceptions\InvalidArgumentException
  */
 public function testNewInstance4()
 {
     \MailSo\Mime\Email::NewInstance('');
 }
Пример #7
0
 /**
  * @param \CAccount $oAccount
  *
  * @return \MailSo\Mime\Message
  *
  * @throws \MailSo\Base\Exceptions\InvalidArgumentException
  */
 private function buildConfirmationMessage($oAccount)
 {
     $sConfirmation = $this->getParamValue('Confirmation', '');
     $sSubject = $this->getParamValue('Subject', '');
     $sText = $this->getParamValue('Text', '');
     if (0 === strlen($sConfirmation) || 0 === strlen($sSubject) || 0 === strlen($sText)) {
         throw new \MailSo\Base\Exceptions\InvalidArgumentException();
     }
     $oMessage = \MailSo\Mime\Message::NewInstance();
     $oMessage->RegenerateMessageId();
     $sXMailer = \CApi::GetConf('webmail.xmailer-value', '');
     if (0 < strlen($sXMailer)) {
         $oMessage->SetXMailer($sXMailer);
     }
     $oTo = \MailSo\Mime\EmailCollection::Parse($sConfirmation);
     if (!$oTo || 0 === $oTo->Count()) {
         throw new \MailSo\Base\Exceptions\InvalidArgumentException();
     }
     $sFrom = 0 < strlen($oAccount->FriendlyName) ? '"' . $oAccount->FriendlyName . '"' : '';
     if (0 < strlen($sFrom)) {
         $sFrom .= ' <' . $oAccount->Email . '>';
     } else {
         $sFrom .= $oAccount->Email;
     }
     $oMessage->SetFrom(\MailSo\Mime\Email::NewInstance($sFrom))->SetTo($oTo)->SetSubject($sSubject);
     $oMessage->AddText($sText, false);
     return $oMessage;
 }