/** * @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; }
/** * @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); } } } } } } }
/** * @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); }
/** * @param mixed $mResponse * @param string $sParent * @param array $aParameters = array() * * @return mixed */ protected function responseObject($mResponse, $sParent = '', $aParameters = array()) { $mResult = $mResponse; if (\is_object($mResponse)) { $bHook = true; $self = $this; $sClassName = \get_class($mResponse); $bHasSimpleJsonFunc = \method_exists($mResponse, 'ToSimpleJSON'); $bThumb = $this->GetCapa(false, \RainLoop\Enumerations\Capa::ATTACHMENT_THUMBNAILS); $oAccountCache = null; $fGetAccount = function () use($self, &$oAccountCache) { if (null === $oAccountCache) { $oAccount = $self->getAccountFromToken(false); $oAccountCache = $oAccount; } return $oAccountCache; }; $aCheckableFoldersCache = null; $fGetCheckableFolder = function () use($self, &$aCheckableFoldersCache) { if (null === $aCheckableFoldersCache) { $oAccount = $self->getAccountFromToken(false); $oSettingsLocal = $self->SettingsProvider(true)->Load($oAccount); $sCheckable = $oSettingsLocal->GetConf('CheckableFolder', '[]'); $aCheckable = @\json_decode($sCheckable); if (!\is_array($aCheckable)) { $aCheckable = array(); } $aCheckableFoldersCache = $aCheckable; } return $aCheckableFoldersCache; }; if ($bHasSimpleJsonFunc) { $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), $mResponse->ToSimpleJSON(true)); } else { if ('MailSo\\Mail\\Message' === $sClassName) { $oAccount = \call_user_func($fGetAccount); $iDateTimeStampInUTC = $mResponse->InternalTimeStampInUTC(); if (0 === $iDateTimeStampInUTC || !!$this->Config()->Get('labs', 'date_from_headers', false)) { $iDateTimeStampInUTC = $mResponse->HeaderTimeStampInUTC(); if (0 === $iDateTimeStampInUTC) { $iDateTimeStampInUTC = $mResponse->InternalTimeStampInUTC(); } } $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('Folder' => $mResponse->Folder(), 'Uid' => (string) $mResponse->Uid(), 'Subject' => \trim(\MailSo\Base\Utils::Utf8Clear($mResponse->Subject())), 'MessageId' => $mResponse->MessageId(), 'Size' => $mResponse->Size(), 'DateTimeStampInUTC' => $iDateTimeStampInUTC, 'ReplyTo' => $this->responseObject($mResponse->ReplyTo(), $sParent, $aParameters), 'From' => $this->responseObject($mResponse->From(), $sParent, $aParameters), 'To' => $this->responseObject($mResponse->To(), $sParent, $aParameters), 'Cc' => $this->responseObject($mResponse->Cc(), $sParent, $aParameters), 'Bcc' => $this->responseObject($mResponse->Bcc(), $sParent, $aParameters), 'Sender' => $this->responseObject($mResponse->Sender(), $sParent, $aParameters), 'DeliveredTo' => $this->responseObject($mResponse->DeliveredTo(), $sParent, $aParameters), 'Priority' => $mResponse->Priority(), 'Threads' => $mResponse->Threads(), 'Sensitivity' => $mResponse->Sensitivity(), 'ExternalProxy' => false, 'ReadReceipt' => '')); $mResult['SubjectParts'] = $this->explodeSubject($mResult['Subject']); $oAttachments = $mResponse->Attachments(); $iAttachmentsCount = $oAttachments ? $oAttachments->Count() : 0; $mResult['HasAttachments'] = 0 < $iAttachmentsCount; $mResult['AttachmentsSpecData'] = $mResult['HasAttachments'] ? $oAttachments->SpecData() : array(); $sSubject = $mResult['Subject']; $mResult['Hash'] = \md5($mResult['Folder'] . $mResult['Uid']); $mResult['RequestHash'] = \RainLoop\Utils::EncodeKeyValuesQ(array('V' => APP_VERSION, 'Account' => $oAccount ? \md5($oAccount->Hash()) : '', 'Folder' => $mResult['Folder'], 'Uid' => $mResult['Uid'], 'MimeType' => 'message/rfc822', 'FileName' => (0 === \strlen($sSubject) ? 'message-' . $mResult['Uid'] : \MailSo\Base\Utils::ClearXss($sSubject)) . '.eml')); // Flags $aFlags = $mResponse->FlagsLowerCase(); $mResult['IsSeen'] = \in_array('\\seen', $aFlags); $mResult['IsFlagged'] = \in_array('\\flagged', $aFlags); $mResult['IsAnswered'] = \in_array('\\answered', $aFlags); $mResult['IsDeleted'] = \in_array('\\deleted', $aFlags); $sForwardedFlag = $this->Config()->Get('labs', 'imap_forwarded_flag', ''); $sReadReceiptFlag = $this->Config()->Get('labs', 'imap_read_receipt_flag', ''); $mResult['IsForwarded'] = 0 < \strlen($sForwardedFlag) && \in_array(\strtolower($sForwardedFlag), $aFlags); $mResult['IsReadReceipt'] = 0 < \strlen($sReadReceiptFlag) && \in_array(\strtolower($sReadReceiptFlag), $aFlags); if (!$this->GetCapa(false, \RainLoop\Enumerations\Capa::COMPOSER, $oAccount)) { $mResult['IsReadReceipt'] = true; } $mResult['TextPartIsTrimmed'] = false; if ('Message' === $sParent) { $oAttachments = $mResponse->Attachments(); $bHasExternals = false; $mFoundedCIDs = array(); $aContentLocationUrls = array(); $mFoundedContentLocationUrls = array(); if ($oAttachments && 0 < $oAttachments->Count()) { $aList =& $oAttachments->GetAsArray(); foreach ($aList as $oAttachment) { if ($oAttachment) { $sContentLocation = $oAttachment->ContentLocation(); if ($sContentLocation && 0 < \strlen($sContentLocation)) { $aContentLocationUrls[] = $oAttachment->ContentLocation(); } } } } $sPlain = ''; $sHtml = \trim($mResponse->Html()); if (0 === \strlen($sHtml)) { $sPlain = \trim($mResponse->Plain()); } $mResult['DraftInfo'] = $mResponse->DraftInfo(); $mResult['InReplyTo'] = $mResponse->InReplyTo(); $mResult['References'] = $mResponse->References(); $fAdditionalDomReader = null; if (0 < \strlen($sHtml) && $this->Config()->Get('labs', 'emogrifier', false)) { if (!\class_exists('Pelago\\Emogrifier', false)) { include_once APP_VERSION_ROOT_PATH . 'app/libraries/emogrifier/Emogrifier.php'; } if (\class_exists('Pelago\\Emogrifier', false)) { $fAdditionalDomReader = function ($oDom) { $oEmogrifier = new \Pelago\Emogrifier(); $oEmogrifier->preserveEncoding = false; return $oEmogrifier->emogrify($oDom); }; } } $fAdditionalExternalFilter = null; if (!!$this->Config()->Get('labs', 'use_local_proxy_for_external_images', false)) { $fAdditionalExternalFilter = function ($sUrl) { return './?/ProxyExternal/' . \RainLoop\Utils::EncodeKeyValuesQ(array('Rnd' => \md5(\microtime(true)), 'Token' => \RainLoop\Utils::GetConnectionToken(), 'Url' => $sUrl)) . '/'; }; } $sHtml = \preg_replace_callback('/(<pre[^>]*>)([\\s\\S\\r\\n\\t]*?)(<\\/pre>)/mi', function ($aMatches) { return \preg_replace('/[\\r\\n]+/', '<br />', $aMatches[1] . \trim($aMatches[2]) . $aMatches[3]); }, $sHtml); $mResult['Html'] = 0 === \strlen($sHtml) ? '' : \MailSo\Base\HtmlUtils::ClearHtml($sHtml, $bHasExternals, $mFoundedCIDs, $aContentLocationUrls, $mFoundedContentLocationUrls, false, false, $fAdditionalExternalFilter, $fAdditionalDomReader, !!$this->Config()->Get('labs', 'try_to_detect_hidden_images', false)); $mResult['ExternalProxy'] = null !== $fAdditionalExternalFilter; $mResult['Plain'] = $sPlain; // $mResult['Plain'] = 0 === \strlen($sPlain) ? '' : \MailSo\Base\HtmlUtils::ConvertPlainToHtml($sPlain); $mResult['TextHash'] = \md5($mResult['Html'] . $mResult['Plain']); $mResult['TextPartIsTrimmed'] = $mResponse->TextPartIsTrimmed(); $mResult['PgpSigned'] = $mResponse->PgpSigned(); $mResult['PgpEncrypted'] = $mResponse->PgpEncrypted(); $mResult['PgpSignature'] = $mResponse->PgpSignature(); unset($sHtml, $sPlain); $mResult['HasExternals'] = $bHasExternals; $mResult['HasInternals'] = \is_array($mFoundedCIDs) && 0 < \count($mFoundedCIDs) || \is_array($mFoundedContentLocationUrls) && 0 < \count($mFoundedContentLocationUrls); $mResult['FoundedCIDs'] = $mFoundedCIDs; $mResult['Attachments'] = $this->responseObject($oAttachments, $sParent, \array_merge($aParameters, array('FoundedCIDs' => $mFoundedCIDs, 'FoundedContentLocationUrls' => $mFoundedContentLocationUrls))); $mResult['ReadReceipt'] = $mResponse->ReadReceipt(); if (0 < \strlen($mResult['ReadReceipt']) && !$mResult['IsReadReceipt']) { if (0 < \strlen($mResult['ReadReceipt'])) { try { $oReadReceipt = \MailSo\Mime\Email::Parse($mResult['ReadReceipt']); if (!$oReadReceipt) { $mResult['ReadReceipt'] = ''; } } catch (\Exception $oException) { unset($oException); } } if (0 < \strlen($mResult['ReadReceipt']) && '1' === $this->Cacher($oAccount)->Get(\RainLoop\KeyPathHelper::ReadReceiptCache($oAccount->Email(), $mResult['Folder'], $mResult['Uid']), '0')) { $mResult['ReadReceipt'] = ''; } } } } else { if ('MailSo\\Mime\\Email' === $sClassName) { $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('Name' => \MailSo\Base\Utils::Utf8Clear($mResponse->GetDisplayName()), 'Email' => \MailSo\Base\Utils::Utf8Clear($mResponse->GetEmail(true)), 'DkimStatus' => $mResponse->GetDkimStatus(), 'DkimValue' => $mResponse->GetDkimValue())); } else { if ('RainLoop\\Providers\\AddressBook\\Classes\\Contact' === $sClassName) { $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('IdContact' => $mResponse->IdContact, 'Display' => \MailSo\Base\Utils::Utf8Clear($mResponse->Display), 'ReadOnly' => $mResponse->ReadOnly, 'IdPropertyFromSearch' => $mResponse->IdPropertyFromSearch, 'Properties' => $this->responseObject($mResponse->Properties, $sParent, $aParameters))); } else { if ('RainLoop\\Providers\\AddressBook\\Classes\\Tag' === $sClassName) { $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('IdContactTag' => $mResponse->IdContactTag, 'Name' => \MailSo\Base\Utils::Utf8Clear($mResponse->Name), 'ReadOnly' => $mResponse->ReadOnly)); } else { if ('RainLoop\\Providers\\AddressBook\\Classes\\Property' === $sClassName) { // Simple hack if ($mResponse && $mResponse->IsWeb()) { $mResponse->Value = \preg_replace('/(skype|ftp|http[s]?)\\\\:\\/\\//i', '$1://', $mResponse->Value); } $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('IdProperty' => $mResponse->IdProperty, 'Type' => $mResponse->Type, 'TypeStr' => $mResponse->TypeStr, 'Value' => \MailSo\Base\Utils::Utf8Clear($mResponse->Value))); } else { if ('MailSo\\Mail\\Attachment' === $sClassName) { $oAccount = $this->getAccountFromToken(false); $mFoundedCIDs = isset($aParameters['FoundedCIDs']) && \is_array($aParameters['FoundedCIDs']) && 0 < \count($aParameters['FoundedCIDs']) ? $aParameters['FoundedCIDs'] : null; $mFoundedContentLocationUrls = isset($aParameters['FoundedContentLocationUrls']) && \is_array($aParameters['FoundedContentLocationUrls']) && 0 < \count($aParameters['FoundedContentLocationUrls']) ? $aParameters['FoundedContentLocationUrls'] : null; if ($mFoundedCIDs || $mFoundedContentLocationUrls) { $mFoundedCIDs = \array_merge($mFoundedCIDs ? $mFoundedCIDs : array(), $mFoundedContentLocationUrls ? $mFoundedContentLocationUrls : array()); $mFoundedCIDs = 0 < \count($mFoundedCIDs) ? $mFoundedCIDs : null; } $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('Folder' => $mResponse->Folder(), 'Uid' => (string) $mResponse->Uid(), 'Framed' => false, 'MimeIndex' => (string) $mResponse->MimeIndex(), 'MimeType' => $mResponse->MimeType(), 'FileName' => \MailSo\Base\Utils::ClearFileName(\MailSo\Base\Utils::ClearXss($mResponse->FileName(true))), 'EstimatedSize' => $mResponse->EstimatedSize(), 'CID' => $mResponse->Cid(), 'ContentLocation' => $mResponse->ContentLocation(), 'IsInline' => $mResponse->IsInline(), 'IsThumbnail' => $bThumb, 'IsLinked' => $mFoundedCIDs && \in_array(\trim(\trim($mResponse->Cid()), '<>'), $mFoundedCIDs) || $mFoundedContentLocationUrls && \in_array(\trim($mResponse->ContentLocation()), $mFoundedContentLocationUrls))); $mResult['Framed'] = $this->isFileHasFramedPreview($mResult['FileName']); if ($mResult['IsThumbnail']) { $mResult['IsThumbnail'] = $this->isFileHasThumbnail($mResult['FileName']); } $mResult['Download'] = \RainLoop\Utils::EncodeKeyValuesQ(array('V' => APP_VERSION, 'Account' => $oAccount ? \md5($oAccount->Hash()) : '', 'Folder' => $mResult['Folder'], 'Uid' => $mResult['Uid'], 'MimeIndex' => $mResult['MimeIndex'], 'MimeType' => $mResult['MimeType'], 'FileName' => $mResult['FileName'], 'Framed' => $mResult['Framed'])); } else { if ('MailSo\\Mail\\Folder' === $sClassName) { $aExtended = null; // $mStatus = $mResponse->Status(); // if (\is_array($mStatus) && isset($mStatus['MESSAGES'], $mStatus['UNSEEN'], $mStatus['UIDNEXT'])) // { // $aExtended = array( // 'MessageCount' => (int) $mStatus['MESSAGES'], // 'MessageUnseenCount' => (int) $mStatus['UNSEEN'], // 'UidNext' => (string) $mStatus['UIDNEXT'], // 'Hash' => $this->MailClient()->GenerateFolderHash( // $mResponse->FullNameRaw(), $mStatus['MESSAGES'], $mStatus['UNSEEN'], $mStatus['UIDNEXT'], // empty($mStatus['HIGHESTMODSEQ']) ? '' : $mStatus['HIGHESTMODSEQ']) // ); // } $aCheckableFolder = \call_user_func($fGetCheckableFolder); if (!\is_array($aCheckableFolder)) { $aCheckableFolder = array(); } $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('Name' => $mResponse->Name(), 'FullName' => $mResponse->FullName(), 'FullNameRaw' => $mResponse->FullNameRaw(), 'FullNameHash' => $this->hashFolderFullName($mResponse->FullNameRaw(), $mResponse->FullName()), 'Delimiter' => (string) $mResponse->Delimiter(), 'HasVisibleSubFolders' => $mResponse->HasVisibleSubFolders(), 'IsSubscribed' => $mResponse->IsSubscribed(), 'IsExists' => $mResponse->IsExists(), 'IsSelectable' => $mResponse->IsSelectable(), 'Flags' => $mResponse->FlagsLowerCase(), 'Checkable' => \in_array($mResponse->FullNameRaw(), $aCheckableFolder), 'Extended' => $aExtended, 'SubFolders' => $this->responseObject($mResponse->SubFolders(), $sParent, $aParameters))); } else { if ('MailSo\\Mail\\MessageCollection' === $sClassName) { $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('MessageCount' => $mResponse->MessageCount, 'MessageUnseenCount' => $mResponse->MessageUnseenCount, 'MessageResultCount' => $mResponse->MessageResultCount, 'Folder' => $mResponse->FolderName, 'FolderHash' => $mResponse->FolderHash, 'UidNext' => $mResponse->UidNext, 'ThreadUid' => $mResponse->ThreadUid, 'NewMessages' => $this->responseObject($mResponse->NewMessages), 'Filtered' => $mResponse->Filtered, 'Offset' => $mResponse->Offset, 'Limit' => $mResponse->Limit, 'Search' => $mResponse->Search)); } else { if ('MailSo\\Mail\\AttachmentCollection' === $sClassName) { $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('InlineCount' => $mResponse->InlineCount())); } else { if ('MailSo\\Mail\\FolderCollection' === $sClassName) { $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('Namespace' => $mResponse->GetNamespace(), 'FoldersHash' => isset($mResponse->FoldersHash) ? $mResponse->FoldersHash : '', 'IsThreadsSupported' => $mResponse->IsThreadsSupported, 'Optimized' => $mResponse->Optimized, 'CountRec' => $mResponse->CountRec(), 'SystemFolders' => isset($mResponse->SystemFolders) && \is_array($mResponse->SystemFolders) ? $mResponse->SystemFolders : array())); } else { if ($mResponse instanceof \MailSo\Base\Collection) { $aList =& $mResponse->GetAsArray(); if (100 < \count($aList) && $mResponse instanceof \MailSo\Mime\EmailCollection) { $aList = \array_slice($aList, 0, 100); } $mResult = $this->responseObject($aList, $sParent, $aParameters); $bHook = false; } else { $mResult = '["' . \get_class($mResponse) . '"]'; $bHook = false; } } } } } } } } } } } } if ($bHook) { $this->Plugins()->RunHook('filter.response-object', array($sClassName, $mResult), false); } } else { if (\is_array($mResponse)) { foreach ($mResponse as $iKey => $oItem) { $mResponse[$iKey] = $this->responseObject($oItem, $sParent, $aParameters); } $mResult = $mResponse; } } unset($mResponse); return $mResult; }
/** * @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; }
/** * @param string $sRawEmails * * @return \MailSo\Mime\EmailCollection */ private function parseEmailAddresses($sRawEmails) { $this->clear(); $sWorkingRecipients = \trim($sRawEmails); if (0 === \strlen($sWorkingRecipients)) { return $this; } $iEmailStartPos = 0; $iEmailEndPos = 0; $bIsInQuotes = false; $sChQuote = '"'; $bIsInAngleBrackets = false; $bIsInBrackets = false; $iCurrentPos = 0; $sWorkingRecipientsLen = \strlen($sWorkingRecipients); while ($iCurrentPos < $sWorkingRecipientsLen) { switch ($sWorkingRecipients[$iCurrentPos]) { case '\'': case '"': if (!$bIsInQuotes) { $sChQuote = $sWorkingRecipients[$iCurrentPos]; $bIsInQuotes = true; } else { if ($sChQuote == $sWorkingRecipients[$iCurrentPos]) { $bIsInQuotes = false; } } break; case '<': if (!$bIsInAngleBrackets) { $bIsInAngleBrackets = true; if ($bIsInQuotes) { $bIsInQuotes = false; } } break; case '>': if ($bIsInAngleBrackets) { $bIsInAngleBrackets = false; } break; case '(': if (!$bIsInBrackets) { $bIsInBrackets = true; } break; case ')': if ($bIsInBrackets) { $bIsInBrackets = false; } break; case ',': case ';': if (!$bIsInAngleBrackets && !$bIsInBrackets && !$bIsInQuotes) { $iEmailEndPos = $iCurrentPos; try { $this->Add(\MailSo\Mime\Email::Parse(\substr($sWorkingRecipients, $iEmailStartPos, $iEmailEndPos - $iEmailStartPos))); $iEmailStartPos = $iCurrentPos + 1; } catch (\MailSo\Base\Exceptions\InvalidArgumentException $oException) { } } break; } $iCurrentPos++; } if ($iEmailStartPos < $iCurrentPos) { try { $this->Add(\MailSo\Mime\Email::Parse(\substr($sWorkingRecipients, $iEmailStartPos, $iCurrentPos - $iEmailStartPos))); } catch (\MailSo\Base\Exceptions\InvalidArgumentException $oException) { } } return $this; }
/** * @param string $sEmail * @param array $aEmails * @param bool $bCreateAuto = true * * @return bool */ public function IncFrec($sEmail, $aEmails, $bCreateAuto = true) { $self = $this; $aEmailsObjects = \array_map(function ($mItem) { $oResult = null; try { $oResult = \MailSo\Mime\Email::Parse(\trim($mItem)); } catch (\Exception $oException) { } return $oResult; }, $aEmails); $aEmailsObjects = \array_filter($aEmailsObjects, function ($oItem) { return !!$oItem; }); if (0 === \count($aEmailsObjects)) { throw new \InvalidArgumentException('Empty Emails argument'); } $this->SyncDatabase(); $iUserID = $this->getUserId($sEmail); $aExists = array(); $aEmailsToCreate = array(); $aEmailsToUpdate = array(); if ($bCreateAuto) { $sSql = 'SELECT prop_value FROM rainloop_ab_properties WHERE id_user = :id_user AND prop_type = :prop_type'; $oStmt = $this->prepareAndExecute($sSql, array(':id_user' => array($iUserID, \PDO::PARAM_INT), ':prop_type' => array(PropertyType::EMAIl, \PDO::PARAM_INT))); if ($oStmt) { $aFetch = $oStmt->fetchAll(\PDO::FETCH_ASSOC); if (\is_array($aFetch) && 0 < \count($aFetch)) { foreach ($aFetch as $aItem) { if ($aItem && !empty($aItem['prop_value'])) { $aExists[] = \MailSo\Base\Utils::StrToLowerIfAscii(\trim($aItem['prop_value'])); } } } } $aEmailsToCreate = \array_filter($aEmailsObjects, function ($oItem) use($aExists, &$aEmailsToUpdate) { if ($oItem) { $sEmail = \trim($oItem->GetEmail(true)); if (0 < \strlen($sEmail)) { $aEmailsToUpdate[] = $sEmail; return !\in_array($sEmail, $aExists); } } return false; }); } else { foreach ($aEmailsObjects as $oItem) { if ($oItem) { $sEmailUpdate = \trim($oItem->GetEmail(true)); if (0 < \strlen($sEmailUpdate)) { $aEmailsToUpdate[] = $sEmailUpdate; } } } } unset($aEmails, $aEmailsObjects); if (0 < \count($aEmailsToCreate)) { $oContact = new \RainLoop\Providers\AddressBook\Classes\Contact(); foreach ($aEmailsToCreate as $oEmail) { if ('' !== \trim($oEmail->GetEmail())) { $oPropEmail = new \RainLoop\Providers\AddressBook\Classes\Property(); $oPropEmail->Type = \RainLoop\Providers\AddressBook\Enumerations\PropertyType::EMAIl; $oPropEmail->Value = \trim($oEmail->GetEmail(true)); $oContact->Properties[] = $oPropEmail; } if ('' !== \trim($oEmail->GetDisplayName())) { $sFirst = $sLast = ''; $sFullName = $oEmail->GetDisplayName(); if (false !== \strpos($sFullName, ' ')) { $aNames = \explode(' ', $sFullName, 2); $sFirst = isset($aNames[0]) ? $aNames[0] : ''; $sLast = isset($aNames[1]) ? $aNames[1] : ''; } else { $sFirst = $sFullName; } if (0 < \strlen($sFirst)) { $oPropName = new \RainLoop\Providers\AddressBook\Classes\Property(); $oPropName->Type = \RainLoop\Providers\AddressBook\Enumerations\PropertyType::FIRST_NAME; $oPropName->Value = \trim($sFirst); $oContact->Properties[] = $oPropName; } if (0 < \strlen($sLast)) { $oPropName = new \RainLoop\Providers\AddressBook\Classes\Property(); $oPropName->Type = \RainLoop\Providers\AddressBook\Enumerations\PropertyType::LAST_NAME; $oPropName->Value = \trim($sLast); $oContact->Properties[] = $oPropName; } } if (0 < \count($oContact->Properties)) { $this->ContactSave($sEmail, $oContact); } $oContact->Clear(); } } $sSql = 'UPDATE rainloop_ab_properties SET prop_frec = prop_frec + 1 WHERE id_user = :id_user AND prop_type = :prop_type'; $aEmailsQuoted = \array_map(function ($mItem) use($self) { return $self->quoteValue($mItem); }, $aEmailsToUpdate); if (1 === \count($aEmailsQuoted)) { $sSql .= ' AND prop_value = ' . $aEmailsQuoted[0]; } else { $sSql .= ' AND prop_value IN (' . \implode(',', $aEmailsQuoted) . ')'; } return !!$this->prepareAndExecute($sSql, array(':id_user' => array($iUserID, \PDO::PARAM_INT), ':prop_type' => array(PropertyType::EMAIl, \PDO::PARAM_INT))); }
/** * @dataProvider providerForParse */ public function testParseWithProvider($sValue, $aResult) { $oMail = \MailSo\Mime\Email::Parse($sValue); $this->assertEquals($aResult, $oMail->ToArray()); }
/** * @param mixed $mResponse * @param string $sParent * @param array $aParameters = array() * * @return mixed */ protected function responseObject($mResponse, $sParent = '', $aParameters = array()) { $mResult = $mResponse; if (\is_object($mResponse)) { $bHook = true; $sClassName = \get_class($mResponse); $bHasSimpleJsonFunc = \method_exists($mResponse, 'ToSimpleJSON'); $bThumb = $this->GetCapa(false, \RainLoop\Enumerations\Capa::ATTACHMENT_THUMBNAILS); if ($bHasSimpleJsonFunc) { $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), $mResponse->ToSimpleJSON(true)); } else { if ('MailSo\\Mail\\Message' === $sClassName) { $oAccount = $this->getAccountFromToken(false); $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('Folder' => $mResponse->Folder(), 'Uid' => (string) $mResponse->Uid(), 'Subject' => \trim(\MailSo\Base\Utils::Utf8Clear($mResponse->Subject())), 'MessageId' => $mResponse->MessageId(), 'Size' => $mResponse->Size(), 'DateTimeStampInUTC' => !!$this->Config()->Get('labs', 'date_from_headers', false) ? $mResponse->HeaderTimeStampInUTC() : $mResponse->InternalTimeStampInUTC(), 'ReplyTo' => $this->responseObject($mResponse->ReplyTo(), $sParent, $aParameters), 'From' => $this->responseObject($mResponse->From(), $sParent, $aParameters), 'To' => $this->responseObject($mResponse->To(), $sParent, $aParameters), 'Cc' => $this->responseObject($mResponse->Cc(), $sParent, $aParameters), 'Bcc' => $this->responseObject($mResponse->Bcc(), $sParent, $aParameters), 'Sender' => $this->responseObject($mResponse->Sender(), $sParent, $aParameters), 'DeliveredTo' => $this->responseObject($mResponse->DeliveredTo(), $sParent, $aParameters), 'Priority' => $mResponse->Priority(), 'Threads' => $mResponse->Threads(), 'ThreadsLen' => $mResponse->ThreadsLen(), 'ParentThread' => $mResponse->ParentThread(), 'Sensitivity' => $mResponse->Sensitivity(), 'ExternalProxy' => false, 'ReadReceipt' => '')); $mResult['SubjectParts'] = $this->explodeSubject($mResult['Subject']); $oAttachments = $mResponse->Attachments(); $iAttachmentsCount = $oAttachments ? $oAttachments->Count() : 0; $mResult['HasAttachments'] = 0 < $iAttachmentsCount; $mResult['AttachmentsMainType'] = ''; if (0 < $iAttachmentsCount) { switch (true) { case $iAttachmentsCount === $oAttachments->ImageCount(): $mResult['AttachmentsMainType'] = 'image'; break; case $iAttachmentsCount === $oAttachments->ArchiveCount(): $mResult['AttachmentsMainType'] = 'archive'; break; case $iAttachmentsCount === $oAttachments->PdfCount(): $mResult['AttachmentsMainType'] = 'pdf'; break; case $iAttachmentsCount === $oAttachments->DocCount(): $mResult['AttachmentsMainType'] = 'doc'; break; case $iAttachmentsCount === $oAttachments->CertificateCount(): $mResult['AttachmentsMainType'] = 'certificate'; break; } } $sSubject = $mResult['Subject']; $mResult['Hash'] = \md5($mResult['Folder'] . $mResult['Uid']); $mResult['RequestHash'] = \RainLoop\Utils::EncodeKeyValues(array('V' => APP_VERSION, 'Account' => $oAccount ? \md5($oAccount->Hash()) : '', 'Folder' => $mResult['Folder'], 'Uid' => $mResult['Uid'], 'MimeType' => 'message/rfc822', 'FileName' => (0 === \strlen($sSubject) ? 'message-' . $mResult['Uid'] : \MailSo\Base\Utils::ClearXss($sSubject)) . '.eml')); // Flags $aFlags = $mResponse->FlagsLowerCase(); $mResult['IsSeen'] = \in_array('\\seen', $aFlags); $mResult['IsFlagged'] = \in_array('\\flagged', $aFlags); $mResult['IsAnswered'] = \in_array('\\answered', $aFlags); $mResult['IsDeleted'] = \in_array('\\deleted', $aFlags); $sForwardedFlag = $this->Config()->Get('labs', 'imap_forwarded_flag', ''); $sReadReceiptFlag = $this->Config()->Get('labs', 'imap_read_receipt_flag', ''); $mResult['IsForwarded'] = 0 < \strlen($sForwardedFlag) && \in_array(\strtolower($sForwardedFlag), $aFlags); $mResult['IsReadReceipt'] = 0 < \strlen($sReadReceiptFlag) && \in_array(\strtolower($sReadReceiptFlag), $aFlags); $mResult['TextPartIsTrimmed'] = false; if ('Message' === $sParent) { $oAttachments = $mResponse->Attachments(); $bHasExternals = false; $mFoundedCIDs = array(); $aContentLocationUrls = array(); $mFoundedContentLocationUrls = array(); if ($oAttachments && 0 < $oAttachments->Count()) { $aList =& $oAttachments->GetAsArray(); foreach ($aList as $oAttachment) { if ($oAttachment) { $sContentLocation = $oAttachment->ContentLocation(); if ($sContentLocation && 0 < \strlen($sContentLocation)) { $aContentLocationUrls[] = $oAttachment->ContentLocation(); } } } } $sPlain = ''; $sHtml = \trim($mResponse->Html()); if (0 === \strlen($sHtml)) { $sPlain = \trim($mResponse->Plain()); } $mResult['DraftInfo'] = $mResponse->DraftInfo(); $mResult['InReplyTo'] = $mResponse->InReplyTo(); $mResult['References'] = $mResponse->References(); $fAdditionalExternalFilter = null; if (!!$this->Config()->Get('labs', 'use_local_proxy_for_external_images', false)) { $fAdditionalExternalFilter = function ($sUrl) { return './?/ProxyExternal/' . \RainLoop\Utils::EncodeKeyValues(array('Rnd' => \md5(\microtime(true)), 'Token' => \RainLoop\Utils::GetConnectionToken(), 'Url' => $sUrl)) . '/'; }; } $mResult['Html'] = 0 === \strlen($sHtml) ? '' : \MailSo\Base\HtmlUtils::ClearHtml($sHtml, $bHasExternals, $mFoundedCIDs, $aContentLocationUrls, $mFoundedContentLocationUrls, false, false, $fAdditionalExternalFilter); $mResult['ExternalProxy'] = null !== $fAdditionalExternalFilter; $mResult['Plain'] = $sPlain; // $mResult['Plain'] = 0 === \strlen($sPlain) ? '' : \MailSo\Base\HtmlUtils::ConvertPlainToHtml($sPlain); $mResult['TextHash'] = \md5($mResult['Html'] . $mResult['Plain']); $mResult['TextPartIsTrimmed'] = $mResponse->TextPartIsTrimmed(); $mResult['PgpSigned'] = $mResponse->PgpSigned(); $mResult['PgpEncrypted'] = $mResponse->PgpEncrypted(); $mResult['PgpSignature'] = $mResponse->PgpSignature(); unset($sHtml, $sPlain); $mResult['HasExternals'] = $bHasExternals; $mResult['HasInternals'] = \is_array($mFoundedCIDs) && 0 < \count($mFoundedCIDs) || \is_array($mFoundedContentLocationUrls) && 0 < \count($mFoundedContentLocationUrls); $mResult['FoundedCIDs'] = $mFoundedCIDs; $mResult['Attachments'] = $this->responseObject($oAttachments, $sParent, \array_merge($aParameters, array('FoundedCIDs' => $mFoundedCIDs, 'FoundedContentLocationUrls' => $mFoundedContentLocationUrls))); $mResult['ReadReceipt'] = $mResponse->ReadReceipt(); if (0 < \strlen($mResult['ReadReceipt']) && !$mResult['IsReadReceipt']) { if (0 < \strlen($mResult['ReadReceipt'])) { try { $oReadReceipt = \MailSo\Mime\Email::Parse($mResult['ReadReceipt']); if (!$oReadReceipt) { $mResult['ReadReceipt'] = ''; } } catch (\Exception $oException) { unset($oException); } } if (0 < \strlen($mResult['ReadReceipt']) && '1' === $this->Cacher($oAccount)->Get(\RainLoop\KeyPathHelper::ReadReceiptCache($oAccount->Email(), $mResult['Folder'], $mResult['Uid']), '0')) { $mResult['ReadReceipt'] = ''; } } } } else { if ('MailSo\\Mime\\Email' === $sClassName) { $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('Name' => \MailSo\Base\Utils::Utf8Clear($mResponse->GetDisplayName()), 'Email' => \MailSo\Base\Utils::Utf8Clear($mResponse->GetEmail(true)), 'DkimStatus' => $mResponse->GetDkimStatus(), 'DkimValue' => $mResponse->GetDkimValue())); } else { if ('RainLoop\\Providers\\AddressBook\\Classes\\Contact' === $sClassName) { $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('IdContact' => $mResponse->IdContact, 'Display' => \MailSo\Base\Utils::Utf8Clear($mResponse->Display), 'ReadOnly' => $mResponse->ReadOnly, 'IdPropertyFromSearch' => $mResponse->IdPropertyFromSearch, 'Properties' => $this->responseObject($mResponse->Properties, $sParent, $aParameters))); } else { if ('RainLoop\\Providers\\AddressBook\\Classes\\Tag' === $sClassName) { $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('IdContactTag' => $mResponse->IdContactTag, 'Name' => \MailSo\Base\Utils::Utf8Clear($mResponse->Name), 'ReadOnly' => $mResponse->ReadOnly)); } else { if ('RainLoop\\Providers\\AddressBook\\Classes\\Property' === $sClassName) { // Simple hack if ($mResponse && $mResponse->IsWeb()) { $mResponse->Value = \preg_replace('/(skype|ftp|http[s]?)\\\\:\\/\\//i', '$1://', $mResponse->Value); } $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('IdProperty' => $mResponse->IdProperty, 'Type' => $mResponse->Type, 'TypeStr' => $mResponse->TypeStr, 'Value' => \MailSo\Base\Utils::Utf8Clear($mResponse->Value))); } else { if ('MailSo\\Mail\\Attachment' === $sClassName) { $oAccount = $this->getAccountFromToken(false); $mFoundedCIDs = isset($aParameters['FoundedCIDs']) && \is_array($aParameters['FoundedCIDs']) && 0 < \count($aParameters['FoundedCIDs']) ? $aParameters['FoundedCIDs'] : null; $mFoundedContentLocationUrls = isset($aParameters['FoundedContentLocationUrls']) && \is_array($aParameters['FoundedContentLocationUrls']) && 0 < \count($aParameters['FoundedContentLocationUrls']) ? $aParameters['FoundedContentLocationUrls'] : null; if ($mFoundedCIDs || $mFoundedContentLocationUrls) { $mFoundedCIDs = \array_merge($mFoundedCIDs ? $mFoundedCIDs : array(), $mFoundedContentLocationUrls ? $mFoundedContentLocationUrls : array()); $mFoundedCIDs = 0 < \count($mFoundedCIDs) ? $mFoundedCIDs : null; } $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('Folder' => $mResponse->Folder(), 'Uid' => (string) $mResponse->Uid(), 'Framed' => false, 'MimeIndex' => (string) $mResponse->MimeIndex(), 'MimeType' => $mResponse->MimeType(), 'FileName' => \MailSo\Base\Utils::ClearFileName(\MailSo\Base\Utils::ClearXss($mResponse->FileName(true))), 'EstimatedSize' => $mResponse->EstimatedSize(), 'CID' => $mResponse->Cid(), 'ContentLocation' => $mResponse->ContentLocation(), 'IsInline' => $mResponse->IsInline(), 'IsThumbnail' => $bThumb, 'IsLinked' => $mFoundedCIDs && \in_array(\trim(\trim($mResponse->Cid()), '<>'), $mFoundedCIDs) || $mFoundedContentLocationUrls && \in_array(\trim($mResponse->ContentLocation()), $mFoundedContentLocationUrls))); $mResult['Framed'] = $this->isFileHasFramedPreview($mResult['FileName']); if ($mResult['IsThumbnail']) { $mResult['IsThumbnail'] = $this->isFileHasThumbnail($mResult['FileName']); } $mResult['Download'] = \RainLoop\Utils::EncodeKeyValues(array('V' => APP_VERSION, 'Account' => $oAccount ? \md5($oAccount->Hash()) : '', 'Folder' => $mResult['Folder'], 'Uid' => $mResult['Uid'], 'MimeIndex' => $mResult['MimeIndex'], 'MimeType' => $mResult['MimeType'], 'FileName' => $mResult['FileName'], 'Framed' => $mResult['Framed'])); } else { if ('MailSo\\Mail\\Folder' === $sClassName) { $aExtended = null; $mStatus = $mResponse->Status(); if (\is_array($mStatus) && isset($mStatus['MESSAGES'], $mStatus['UNSEEN'], $mStatus['UIDNEXT'])) { $aExtended = array('MessageCount' => (int) $mStatus['MESSAGES'], 'MessageUnseenCount' => (int) $mStatus['UNSEEN'], 'UidNext' => (string) $mStatus['UIDNEXT'], 'Hash' => \MailSo\Mail\MailClient::GenerateHash($mResponse->FullNameRaw(), $mStatus['MESSAGES'], $mStatus['UNSEEN'], $mStatus['UIDNEXT'])); } $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('Name' => $mResponse->Name(), 'FullName' => $mResponse->FullName(), 'FullNameRaw' => $mResponse->FullNameRaw(), 'FullNameHash' => $this->hashFolderFullName($mResponse->FullNameRaw(), $mResponse->FullName()), 'Delimiter' => (string) $mResponse->Delimiter(), 'HasVisibleSubFolders' => $mResponse->HasVisibleSubFolders(), 'IsSubscribed' => $mResponse->IsSubscribed(), 'IsExists' => $mResponse->IsExists(), 'IsSelectable' => $mResponse->IsSelectable(), 'Flags' => $mResponse->FlagsLowerCase(), 'Extended' => $aExtended, 'SubFolders' => $this->responseObject($mResponse->SubFolders(), $sParent, $aParameters))); } else { if ('MailSo\\Mail\\MessageCollection' === $sClassName) { $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('MessageCount' => $mResponse->MessageCount, 'MessageUnseenCount' => $mResponse->MessageUnseenCount, 'MessageResultCount' => $mResponse->MessageResultCount, 'Folder' => $mResponse->FolderName, 'FolderHash' => $mResponse->FolderHash, 'UidNext' => $mResponse->UidNext, 'NewMessages' => $this->responseObject($mResponse->NewMessages), 'LastCollapsedThreadUids' => $mResponse->LastCollapsedThreadUids, 'Offset' => $mResponse->Offset, 'Limit' => $mResponse->Limit, 'Search' => $mResponse->Search)); } else { if ('MailSo\\Mail\\AttachmentCollection' === $sClassName) { $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('InlineCount' => $mResponse->InlineCount())); } else { if ('MailSo\\Mail\\FolderCollection' === $sClassName) { $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('Namespace' => $mResponse->GetNamespace(), 'FoldersHash' => isset($mResponse->FoldersHash) ? $mResponse->FoldersHash : '', 'IsThreadsSupported' => $mResponse->IsThreadsSupported, 'Optimized' => $mResponse->Optimized, 'SystemFolders' => isset($mResponse->SystemFolders) && \is_array($mResponse->SystemFolders) ? $mResponse->SystemFolders : array())); } else { if ($mResponse instanceof \MailSo\Base\Collection) { $aList =& $mResponse->GetAsArray(); if (100 < \count($aList) && $mResponse instanceof \MailSo\Mime\EmailCollection) { $aList = \array_slice($aList, 0, 100); } $mResult = $this->responseObject($aList, $sParent, $aParameters); $bHook = false; } else { if ('RainLoop\\Providers\\AddressBook\\Classes\\Group' === $sClassName) { $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('IdGroup' => $mResponse->IdGroup, 'Name' => $mResponse->Name, 'Contacts' => $this->responseObject($mResponse->Contacts, $sParent, $aParameters))); } else { if ('RainLoop\\Providers\\AddressBook\\Classes\\GroupContact' === $sClassName) { $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array('IdContact' => $mResponse->IdContact, 'IdGroup' => $mResponse->IdGroup, 'Name' => $mResponse->Name, 'Email' => $mResponse->Email, 'Phone' => $mResponse->Phone)); } else { $mResult = '["' . \get_class($mResponse) . '"]'; $bHook = false; } } } } } } } } } } } } } } if ($bHook) { $this->Plugins()->RunHook('filter.response-object', array($sClassName, $mResult), false); } } else { if (\is_array($mResponse)) { foreach ($mResponse as $iKey => $oItem) { $mResponse[$iKey] = $this->responseObject($oItem, $sParent, $aParameters); } $mResult = $mResponse; } } unset($mResponse); return $mResult; }
/** * @expectedException \MailSo\Base\Exceptions\InvalidArgumentException */ public function testParse6() { $oMail = \MailSo\Mime\Email::Parse('example.com'); }
/** * @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; }