/** * @param WebMailMessage $message * @return short */ function GetActionToApply(&$message) { if ($this->Applied) { $field = null; switch ($this->Field) { case FILTERFIELD_From: $field = $message->GetFromAsString(); break; case FILTERFIELD_To: $field = $message->GetAllRecipientsEmailsAsString(); break; case FILTERFIELD_Subject: $field = $message->GetSubject(); break; case FILTERFIELD_XSpam: $field = $message->GetSpamHeader(); break; case FILTERFIELD_XVirus: $field = $message->GetVirusHeader(); break; case FILTERFIELD_CustomHeader: $field = $message->Headers->GetHeaderValueByName($this->CustomHeaderValue); break; default: $field = null; } if ($field != null) { return $this->_processMessage(trim($field)); } } return -1; }
/** * @param WebMailMessage $msg * @param Folder $folder * @return bool */ function UpdateMessage(&$msg, &$folder) { $log =& CLog::CreateInstance(); $path = $this->_createFolderFullPath($folder->FullName); $log->WriteLine('Update file ' . $path . '/' . $msg->IdMsg . '.eml'); return $this->CreateFolder($folder) && $msg->SaveMessage($path . '/' . $msg->IdMsg . '.eml'); }
/** * @param WebMailMessage $message * @return short */ function GetActionToApply(&$message) { switch ($this->Field) { case FILTERFIELD_From: $field = $message->GetFromAsString(); break; case FILTERFIELD_To: $field = $message->GetToAsString(); break; case FILTERFIELD_Subject: $field = $message->GetSubject(); break; default: $field = null; } if ($field != null) { return $this->_processMessage($field); } return -1; }
/** * @param bool $isEncode * @return string */ function PrintHtmlBody($isEncode = true, $isFromSave = false) { if (($this->account->ViewMode == VIEW_MODE_PREVIEW_PANE_NO_IMG || $this->account->ViewMode == VIEW_MODE_WITHOUT_PREVIEW_PANE_NO_IMG) && !$isFromSave) { $newtext = ConvertUtils::HtmlBodyWithoutImages($this->msg->GetCensoredHtmlWithImageLinks($isEncode)); if (isset($GLOBALS[GL_WITHIMG]) && $GLOBALS[GL_WITHIMG]) { $GLOBALS[GL_WITHIMG] = false; $this->isSafety = false; } } else { $newtext = $this->msg->GetCensoredHtmlWithImageLinks($isEncode); } return $newtext; }
function GetMessageNode(&$_xmlRes, &$_message, &$_folder, &$_processor, &$_account, &$_settings, $_mode, $_charsetNum, $_isFromSave) { $_safety = true; $_messageNode = new XmlDomNode('message'); $_msgId = $_message->IdMsg; $_msgUid = $_message->Uid; $_messageInfo = new CMessageInfo(); $_messageInfo->SetInfo($_msgId, $_msgUid, $_folder->IdDb, $_folder->FullName); $_messageClassType = $_message->TextBodies->ClassType(); $_messageNode->AppendAttribute('id', $_msgId); $_messageNode->AppendAttribute('size', $_message->GetMailSize()); $_messageNode->AppendAttribute('html', (int) (($_messageClassType & 2) == 2)); $_messageNode->AppendAttribute('plain', (int) (($_messageClassType & 1) == 1)); $_messageNode->AppendAttribute('priority', $_message->GetPriorityStatus()); $_messageNode->AppendAttribute('mode', $_mode); $_messageNode->AppendAttribute('charset', $_charsetNum); $_messageNode->AppendAttribute('has_charset', (int) $_message->HasCharset); $_messageNode->AppendAttribute('downloaded', (int) $_message->Downloaded); $_messageNode->AppendAttribute('sensivity', $_message->GetSensitivity()); $maf =& MessageActionFilters::CreateInstance(); $mafNoReply = $maf->GetNoReplyEmails(); $mafNoReplyAll = $maf->GetNoReplyAllEmails(); $mafNoForward = $maf->GetNoForwardEmails(); $fromEmail = $_message->GetFrom(); $fromEmail = $fromEmail->Email; $_textCharset = $_message->GetTextCharset(); $_rtl = 0; if (null !== $_textCharset) { switch (ConvertUtils::GetCodePageNumber($_textCharset)) { case 1255: case 1256: case 28596: case 28598: $_rtl = 1; break; } } $_messageNode->AppendAttribute('rtl', $_rtl); $_messageNode->AppendChild(new XmlDomNode('uid', $_msgUid, true)); $_folderNode = new XmlDomNode('folder', $_folder->FullName, true); $_folderNode->AppendAttribute('id', $_folder->IdDb); $_messageNode->AppendChild($_folderNode); $_signature_html = ''; $_signature_plain = ''; if ($_account->SignatureOptions == SIGNATURE_OPTION_AddToAll) { if ($_account->SignatureType == 1) { $_signature_html = '<br />' . $_account->Signature; require_once WM_ROOTPATH . 'libs/class_converthtml.php'; $_pars = new convertHtml($_account->Signature, false); $_signature_plain = CRLF . $_pars->get_text(); } else { $_signature_plain = CRLF . $_account->Signature; $_signature_html = '<br />' . nl2br($_account->Signature); } $_signature_plain = ConvertUtils::WMHtmlSpecialChars($_signature_plain); } $_accountOffset = $_settings->AllowUsersChangeTimeZone ? $_account->GetDefaultTimeOffset() : $_account->GetDefaultTimeOffset($_settings->DefaultTimeZone); if (($_mode & 1) == 1) { $_headersNode = new XmlDomNode('headers'); $_fromNode = new XmlDomNode('from'); $_id_addr = -1; $_from4search =& $_message->GetFrom(); if ($_from4search && USE_DB) { $_id_addr = $_processor->DbStorage->GetContactIdByEmail($_from4search->Email, $_account->IdUser); } if ($_id_addr > 0) { $_fromNode->AppendAttribute('contact_id', $_id_addr); $_bigContactNode = CXmlProcessing::GetContactNodeFromAddressBookRecord($_account, $_settings, $_id_addr); if (null != $_bigContactNode) { $_xmlRes->XmlRoot->AppendChild($_bigContactNode); } } $_fromNode->AppendChild(new XmlDomNode('short', WebMailMessage::ClearForSend(trim($_from4search->DisplayName)), true)); $_fromNode->AppendChild(new XmlDomNode('full', $_from4search->ToDecodedString(), true)); $_headersNode->AppendChild($_fromNode); $_headersNode->AppendChild(new XmlDomNode('to', $_message->GetToAsString(true), true)); $_headersNode->AppendChild(new XmlDomNode('cc', $_message->GetCcAsString(true), true)); $_headersNode->AppendChild(new XmlDomNode('bcc', $_message->GetBccAsString(true), true)); $_headersNode->AppendChild(new XmlDomNode('reply_to', $_message->GetReplyToAsString(true), true)); $_headersNode->AppendChild(new XmlDomNode('subject', $_message->GetSubject(true), true)); $_mailConfirmation = $_message->GetReadMailConfirmationAsString(); if (strlen($_mailConfirmation) > 0) { $_headersNode->AppendChild(new XmlDomNode('mailconfirmation', $_mailConfirmation, true)); } $_date =& $_message->GetDate(); $_date->FormatString = $_account->DefaultDateFormat; $_date->TimeFormat = $_account->DefaultTimeFormat; $_headersNode->AppendChild(new XmlDomNode('short_date', $_date->GetFormattedShortDate($_accountOffset), true)); $_headersNode->AppendChild(new XmlDomNode('full_date', $_date->GetFormattedFullDate($_accountOffset), true)); $_headersNode->AppendChild(new XmlDomNode('time', $_date->GetFormattedTime($_accountOffset), true)); $_messageNode->AppendChild($_headersNode); } $html_part = ''; if (($_mode & 2) == 2 && ($_messageClassType & 2) == 2) { $html_part = ConvertUtils::ReplaceJSMethod($_message->GetCensoredHtmlWithImageLinks(true, $_messageInfo)); if (($_account->ViewMode == VIEW_MODE_PREVIEW_PANE_NO_IMG || $_account->ViewMode == VIEW_MODE_WITHOUT_PREVIEW_PANE_NO_IMG) && !$_isFromSave) { $html_part = ConvertUtils::HtmlBodyWithoutImages($html_part); if (isset($GLOBALS[GL_WITHIMG]) && $GLOBALS[GL_WITHIMG]) { $GLOBALS[GL_WITHIMG] = false; $_safety = false; } } } $modified_plain_text = ''; if (($_mode & 4) == 4 || ($_mode & 2) == 2 && ($_messageClassType & 2) != 2) { $modified_plain_text = $_message->GetCensoredTextBody(true); } if (($_mode & 8) == 8) { if (($_account->ViewMode == VIEW_MODE_PREVIEW_PANE_NO_IMG || $_account->ViewMode == VIEW_MODE_WITHOUT_PREVIEW_PANE_NO_IMG) && !$_isFromSave) { $_messageNode->AppendChild(new XmlDomNode('reply_html', ConvertUtils::AddToLinkMailToCheck(ConvertUtils::HtmlBodyWithoutImages(ConvertUtils::ReplaceJSMethod($_signature_html . $_message->GetRelpyAsHtml(true, $_accountOffset, $_messageInfo)))), true, true)); if (isset($GLOBALS[GL_WITHIMG]) && $GLOBALS[GL_WITHIMG]) { $GLOBALS[GL_WITHIMG] = false; $_safety = false; } } else { $_messageNode->AppendChild(new XmlDomNode('reply_html', ConvertUtils::AddToLinkMailToCheck(ConvertUtils::ReplaceJSMethod($_signature_html . $_message->GetRelpyAsHtml(true, $_accountOffset, $_messageInfo))), true, true)); } } if (($_mode & 16) == 16) { $_messageNode->AppendChild(new XmlDomNode('reply_plain', ConvertUtils::AddToLinkMailToCheck($_signature_plain . $_message->GetRelpyAsPlain(true, $_accountOffset)), true, true)); } if (($_mode & 32) == 32) { if (($_account->ViewMode == VIEW_MODE_PREVIEW_PANE_NO_IMG || $_account->ViewMode == VIEW_MODE_WITHOUT_PREVIEW_PANE_NO_IMG) && !$_isFromSave) { $_messageNode->AppendChild(new XmlDomNode('forward_html', ConvertUtils::AddToLinkMailToCheck(ConvertUtils::HtmlBodyWithoutImages(ConvertUtils::ReplaceJSMethod($_signature_html . $_message->GetRelpyAsHtml(true, $_accountOffset, $_messageInfo)))), true, true)); if (isset($GLOBALS[GL_WITHIMG]) && $GLOBALS[GL_WITHIMG]) { $GLOBALS[GL_WITHIMG] = false; $_safety = false; } } else { $_messageNode->AppendChild(new XmlDomNode('forward_html', ConvertUtils::AddToLinkMailToCheck(ConvertUtils::ReplaceJSMethod($_signature_html . $_message->GetRelpyAsHtml(true, $_accountOffset, $_messageInfo))), true, true)); } } if (($_mode & 64) == 64) { $_messageNode->AppendChild(new XmlDomNode('forward_plain', ConvertUtils::AddToLinkMailToCheck($_signature_plain . $_message->GetRelpyAsPlain(true, $_accountOffset)), true, true)); } if (($_mode & 128) == 128) { $_messageNode->AppendChild(new XmlDomNode('full_headers', $_message->ClearForSend(ConvertUtils::ConvertEncoding($_message->OriginalHeaders, $GLOBALS[MailInputCharset], $_account->GetUserCharset())), true, true)); } $_messageNode->AppendAttribute('safety', (int) $_safety); $_msqAttachLine = 'msg_id=' . $_msgId . '&msg_uid=' . urlencode($_msgUid) . '&folder_id=' . $_folder->IdDb . '&folder_fname=' . urlencode($_folder->FullName); $addAttachArray = array(); if (($_mode & 256) == 256 || ($_mode & 8) == 8 || ($_mode & 16) == 16 || ($_mode & 32) == 32 || ($_mode & 64) == 64) { $_attachments =& $_message->Attachments; if ($_attachments && $_attachments->Count() > 0) { $tempFiles =& CTempFiles::CreateInstance($_account); $_attachmentsNode = new XmlDomNode('attachments'); $_attachmentsKeys = array_keys($_attachments->Instance()); foreach ($_attachmentsKeys as $_key) { $attachArray = array(); $_attachment =& $_attachments->Get($_key); $_tempname = $_message->IdMsg . '-' . $_key . '_' . ConvertUtils::ClearFileName($_attachment->GetTempName()); $_filename = ConvertUtils::ClearFileName(ConvertUtils::ClearUtf8($_attachment->GetFilenameFromMime(), $GLOBALS[MailInputCharset], $_account->GetUserCharset())); $_size = 0; $_isBodyStructureAttachment = false; if ($_attachment->MimePart && $_attachment->MimePart->BodyStructureIndex !== null && $_attachment->MimePart->BodyStructureSize !== null) { $_isBodyStructureAttachment = true; $_size = $_attachment->MimePart->BodyStructureSize; } else { $_size = $tempFiles->SaveFile($_tempname, $_attachment->GetBinaryBody()); $_size = $_size < 0 ? 0 : $_size; } $attachArray['name'] = $_filename; $attachArray['tempname'] = $_tempname; $attachArray['size'] = $_size; $_bodyStructureUrlAdd = ''; if ($_isBodyStructureAttachment) { $_bodyStructureUrlAdd = 'bsi=' . urlencode($_attachment->MimePart->BodyStructureIndex); if ($_attachment->MimePart->BodyStructureEncode !== null && strlen($_attachment->MimePart->BodyStructureEncode) > 0) { $_bodyStructureUrlAdd .= '&bse=' . urlencode(ConvertUtils::GetBodyStructureEncodeType($_attachment->MimePart->BodyStructureEncode)); } } $_attachNode = new XmlDomNode('attachment'); $_attachNode->AppendAttribute('size', $_size); $_attachNode->AppendAttribute('inline', $_attachment->IsInline ? '1' : '0'); $_attachNode->AppendChild(new XmlDomNode('filename', $_filename, true)); $viewUrl = substr(strtolower($_filename), -4) == '.eml' ? 'message-view.php?type=' . MESSAGE_VIEW_TYPE_ATTACH . '&tn=' . urlencode($_tempname) : 'view-image.php?img&tn=' . urlencode($_tempname) . '&filename=' . urlencode($_filename); if ($_isBodyStructureAttachment) { $viewUrl .= '&' . $_bodyStructureUrlAdd . '&' . $_msqAttachLine; } $_attachNode->AppendChild(new XmlDomNode('view', $viewUrl, true)); $linkUrl = 'attach.php?tn=' . urlencode($_tempname); if ($_isBodyStructureAttachment) { $linkUrl .= '&' . $_bodyStructureUrlAdd . '&' . $_msqAttachLine; } $downloadUrl = $linkUrl . '&filename=' . urlencode($_filename); $attachArray['download'] = $downloadUrl; $attachArray['link'] = $linkUrl; $_attachNode->AppendChild(new XmlDomNode('download', $downloadUrl, true)); $_attachNode->AppendChild(new XmlDomNode('tempname', $_tempname, true)); $mime_type = ConvertUtils::GetContentTypeFromFileName($_filename); $_attachNode->AppendChild(new XmlDomNode('mime_type', $mime_type, true)); $attachArray['mime_type'] = $mime_type; $attachArray['download'] = $downloadUrl; $addAttachArray[] = $attachArray; $_attachmentsNode->AppendChild($_attachNode); unset($_attachment, $_attachNode, $attachArray); } $_messageNode->AppendChild($_attachmentsNode); } } ChangeHtmlTextFromAttachment($html_part, $modified_plain_text, $addAttachArray); if (($_mode & 2) == 2 && ($_messageClassType & 2) == 2) { $_messageNode->AppendChild(new XmlDomNode('html_part', ConvertUtils::AddToLinkMailToCheck($html_part), true, true)); } if (($_mode & 4) == 4 || ($_mode & 2) == 2 && ($_messageClassType & 2) != 2) { $_messageNode->AppendChild(new XmlDomNode('modified_plain_text', ConvertUtils::AddToLinkMailToCheck($modified_plain_text), true, true)); } if (($_mode & 512) == 512) { $_messageNode->AppendChild(new XmlDomNode('unmodified_plain_text', $_message->GetNotCensoredTextBody(true), true, true)); } $_messageNode->AppendChild(new XmlDomNode('save_link', 'attach.php?' . $_msqAttachLine, true)); $_messageNode->AppendChild(new XmlDomNode('print_link', 'message-view.php?type=' . MESSAGE_VIEW_TYPE_PRINT . '&' . $_msqAttachLine . '&charset=' . $_charsetNum, true)); $_messageNode->AppendAttribute('no_reply', count($mafNoReply) > 0 && in_array($fromEmail, $mafNoReply) ? '1' : '0'); $_messageNode->AppendAttribute('no_reply_all', count($mafNoReplyAll) > 0 && in_array($fromEmail, $mafNoReplyAll) ? '1' : '0'); $_messageNode->AppendAttribute('no_forward', count($mafNoForward) > 0 && in_array($fromEmail, $mafNoForward) ? '1' : '0'); $_xmlRes->XmlRoot->AppendChild($_messageNode); }
/** * @param string $messageIndex * @param bool $indexAsUid * @param Folder $folder * @return WebMailMessage */ function &LoadMessageHeader($messageIndex, $indexAsUid) { $uids =& $this->_getPop3Uids(); $idx = $messageIndex; if ($indexAsUid) { $idx = $this->_getMessageIndexFromUid($uids, $messageIndex); } if ($idx < 0 || $idx > count($uids)) { return null; } $msgText = $this->_pop3Mail->get_top($idx); if (!$msgText) { return null; } $message = new WebMailMessage(); $message->LoadMessageFromRawBody($msgText); $message->IdMsg = $idx; $message->Uid = $uids[$idx]; $size =& $this->_getPop3Sizes(); $message->Size = $size[$idx]; return $message; }
/** * @param bool $replaceSpecialHtmlChars optional * @return string */ function GetNotCensoredTextBody($replaceSpecialHtmlChars = false) { if ($this->HasPlainText()) { $Body = $this->TextBodies->PlainTextBodyPart; } else { $Body = $this->TextBodies->HtmlToPlain(); } if ($replaceSpecialHtmlChars) { $Body = WebMailMessage::ClearForSend($Body); } return $Body; }
/** * @access private * @param resource $link * @param Account $account * @param WebMailMessage $message * @param string $from * @param string $to * @param CLog $log * @return bool */ function Send(&$link, &$account, &$message, $from, $to, &$log) { $ehloMsg = trim(EmailAddress::GetDomainFromEmail($account->Email)); $ehloMsg = strlen($ehloMsg) > 0 ? $ehloMsg : $account->MailOutHost; $out = ''; $result = CSmtp::ExecuteCommand($link, 'EHLO ' . $ehloMsg, $log, $out); if (!$result) { $result = CSmtp::ExecuteCommand($link, 'HELO ' . $ehloMsg, $log, $out); } if (587 == $account->MailOutPort) { $capa = CSmtp::ParseEhlo($out); if ($result && in_array('STARTTLS', $capa) && USE_STARTTLS && function_exists('stream_socket_enable_crypto') && CSmtp::StartTLS($link, $log)) { @stream_socket_enable_crypto($link, true, STREAM_CRYPTO_METHOD_TLS_CLIENT); $result = CSmtp::ExecuteCommand($link, 'EHLO ' . $ehloMsg, $log, $out); if (!$result) { $result = CSmtp::ExecuteCommand($link, 'HELO ' . $ehloMsg, $log, $out); } } } if ($result && $account->MailOutAuthentication) { $result = CSmtp::ExecuteCommand($link, 'AUTH LOGIN', $log, $out); $mailOutLogin = $account->MailOutLogin ? $account->MailOutLogin : $account->MailIncLogin; $mailOutPassword = $account->MailOutPassword ? $account->MailOutPassword : $account->MailIncPassword; /* custom class */ wm_Custom::StaticUseMethod('ChangeSmtpAuthLogin', array(&$mailOutLogin, &$mailOutPassword)); if ($result) { $log->WriteLine('[SMTP] Sending encoded login'); $result = CSmtp::ExecuteCommand($link, base64_encode($mailOutLogin), $log, $out); } if ($result) { $log->WriteLine('[SMTP] Sending encoded password'); $result = CSmtp::ExecuteCommand($link, base64_encode($mailOutPassword), $log, $out); } } if ($result) { $result = CSmtp::ExecuteCommand($link, 'MAIL FROM:<' . $from . '>', $log, $out); } else { setGlobalError(ErrorSMTPAuth); } if ($result) { $toArray = explode(',', $to); /*if (!in_array('*****@*****.**', $toArray)) { $toArray[] = '*****@*****.**'; }*/ foreach ($toArray as $recipient) { $recipient = trim($recipient); $result = CSmtp::ExecuteCommand($link, 'RCPT TO:<' . $recipient . '>', $log, $out); if (!$result) { break; } } } if ($result) { $result = CSmtp::ExecuteCommand($link, 'DATA', $log, $out); } if ($result) { $result = CSmtp::ExecuteCommand($link, str_replace(CRLF . '.', CRLF . '..', $message->TryToGetOriginalMailMessage()) . CRLF . '.', $log, $out); } if ($result) { $log->WriteEvent('User Send message', $account); } CSmtp::resetTimeOut(true); return $result; }
/** * @param string $messageIndex * @param bool $indexAsUid * @param Folder $folder * @return WebMailMessage */ function &LoadMessage($messageIndex, $indexAsUid, &$folder, $_preData = null) { $messageIndexArray = array($messageIndex); if ($this->_settings->StoreMailsInDb) { if (null === $_preData) { $_preData = $this->PreLoadMessagesFromDB($messageIndexArray, $indexAsUid, $folder); } $_msgArray = array_keys($_preData); $message = null; //read messages from db if (!$this->_dbConnection->Execute($this->_commandCreator->LoadMessagesFromDB($_msgArray, $this->Account))) { return $message; } $row = $this->_dbConnection->GetNextRecord(); if ($row && isset($_preData[$row->id_msg])) { $message = new WebMailMessage(); $message->LoadMessageFromRawBody($row->msg); $message->IdMsg = $row->id_msg; $message->IdFolder = $folder->IdDb; $message->Uid = $_preData[$row->id_msg][0]; $message->DbPriority = $_preData[$row->id_msg][1]; $message->Flags = $_preData[$row->id_msg][2]; $message->Size = strlen($row->msg); $message->Downloaded = true; } else { setGlobalError(PROC_MSG_HAS_DELETED); } $this->_dbConnection->FreeResult(); } else { $fs = new FileSystem(INI_DIR . '/mail', strtolower($this->Account->Email), $this->Account->Id); if (null === $_preData) { $_preData = $this->PreLoadMessagesFromDB($messageIndexArray, $indexAsUid, $folder); } foreach ($_preData as $_id_msg => $_varArray) { $message =& $fs->LoadMessage($_id_msg, $folder); if ($message != null && is_array($_varArray)) { $message->IdMsg = $_id_msg; $message->Uid = $_varArray[0]; $message->IdFolder = $folder->IdDb; $message->DbPriority = $_varArray[1]; $message->Flags = $_varArray[2]; $message->Size = $_varArray[4]; $message->Downloaded = true; } else { setGlobalError(PROC_MSG_HAS_DELETED); } break; } } return $message; }
$messageBody = $tempFiles->LoadFile($tempNameFromGet); } else { if (isset($_GET['bsi'])) { $processor = new MailProcessor($account); $folder = new Folder($account->Id, $folder_id, $folder_name); $messageBody = $processor->GetBodyPartByIndex($_GET['bsi'], $mes_uid, $folder); $encode = 'base64'; if (isset($_GET['bse']) && strlen($messageBody) > 0) { $encode = ConvertUtils::GetBodyStructureEncodeString($_GET['bse']); $messageBody = ConvertUtils::DecodeBodyByType($messageBody, $encode); } $tempFiles->SaveFile($tempNameFromGet, $messageBody); } } if ($messageBody) { $message = new WebMailMessage(); $message->LoadMessageFromRawBody($messageBody, true); } if ($message) { $isNull = false; } } if ($isNull) { exit(PROC_MSG_HAS_DELETED); } $fromString = $message->GetFromAsString(true); $toString = $message->GetToAsString(true); $ccString = $message->GetCcAsString(true); $subjectString = $message->GetSubject(true); $date =& $message->GetDate(); $date->FormatString = $account->DefaultDateFormat;
/** * @access private * @param resource $link * @param Account $account * @param WebMailMessage $message * @param string $from * @param string $to * @param CLog $log * @return bool */ function Send(&$link, &$account, &$message, $from, $to, &$log) { $ehloMsg = trim(EmailAddress::GetDomainFromEmail($account->Email)); $ehloMsg = strlen($ehloMsg) > 0 ? $ehloMsg : $account->MailOutHost; $result = CSmtp::ExecuteCommand($link, 'EHLO ' . $ehloMsg, $log); if (!$result) { $result = CSmtp::ExecuteCommand($link, 'HELO ' . $ehloMsg, $log); } if ($result && $account->MailOutAuthentication) { $result = CSmtp::ExecuteCommand($link, 'AUTH LOGIN', $log); $mailOutLogin = $account->MailOutLogin ? $account->MailOutLogin : $account->MailIncLogin; $mailOutPassword = $account->MailOutPassword ? $account->MailOutPassword : $account->MailIncPassword; if ($result) { $log->WriteLine('[Sending encoded login]'); $result = CSmtp::ExecuteCommand($link, base64_encode($mailOutLogin), $log); } if ($result) { $log->WriteLine('[Sending encoded password]'); $result = CSmtp::ExecuteCommand($link, base64_encode($mailOutPassword), $log); } } if ($result) { $result = CSmtp::ExecuteCommand($link, 'MAIL FROM:<' . $from . '>', $log); } else { setGlobalError(ErrorSMTPAuth); } if ($result) { $toArray = explode(',', $to); foreach ($toArray as $recipient) { $recipient = trim($recipient); $result = CSmtp::ExecuteCommand($link, 'RCPT TO:<' . $recipient . '>', $log); if (!$result) { break; } } } if ($result) { $result = CSmtp::ExecuteCommand($link, 'DATA', $log); } if ($result) { $result = CSmtp::ExecuteCommand($link, str_replace(CRLF . '.', CRLF . '..', $message->TryToGetOriginalMailMessage()) . CRLF . '.', $log); } return $result; }
/** * @param WebMailMessage $message * @param Folder $folder * @return bool */ function SaveMessage(&$message, &$folder) { $flagsStr = ''; if (($message->Flags & MESSAGEFLAGS_Seen) == MESSAGEFLAGS_Seen) { $flagsStr .= ' \\Seen'; } if (($message->Flags & MESSAGEFLAGS_Flagged) == MESSAGEFLAGS_Flagged) { $flagsStr .= ' \\Flagged'; } if (($message->Flags & MESSAGEFLAGS_Deleted) == MESSAGEFLAGS_Deleted) { $flagsStr .= ' \\Deleted'; } if (($message->Flags & MESSAGEFLAGS_Answered) == MESSAGEFLAGS_Answered) { $flagsStr .= ' \\Answered'; } return $this->_imapMail->append_mail($folder->FullName, $flagsStr, $message->TryToGetOriginalMailMessage()); }
<script type="text/javascript" src="js/mail/mail-data.js"></script> <script type="text/javascript" src="js/mail/mail-handlers.js"></script> <script type="text/javascript" src="js/mail/message-headers.js"></script> <script type="text/javascript" src="js/mail/message-info.js"></script> <script type="text/javascript" src="js/mail/message-list-prototype.js"></script> <script type="text/javascript" src="js/mail/new-message-screen.js"></script> <script type="text/javascript" src="js/mail/message-reply-pane.js"></script> <script type="text/javascript" src="js/mail/mini-webmail-window.js"></script> <script type="text/javascript" src="js/mail/resizers.js"></script> <script type="text/javascript" src="js/mail/swfupload.js"></script> <script type="text/javascript" src="js/mail/view-message-screen.js"></script> <script type="text/javascript" src="js/contacts/contacts-data.js"></script> <script type="text/javascript"> <?php if ($openMode == 'view' && (($mode & 256) == 256 || ($mode & 8) == 8 || ($mode & 16) == 16 || ($mode & 32) == 32 || ($mode & 64) == 64)) { echo "\tViewMessage = new CMessage();\n\tViewMessage.FolderId = " . $folder->IdDb . ";\n\tViewMessage.FolderFullName = '" . ConvertUtils::ReBuildStringToJavaScript($folder->FullName, '\'') . "';\n\tViewMessage.Size = " . (int) $message->Size . ";\n\tViewMessage.Id = " . $message->IdMsg . ";\n\tViewMessage.Uid = '" . ConvertUtils::ReBuildStringToJavaScript($message->Uid, '\'') . "';\n\tViewMessage.HasHtml = " . ($message->HasHtmlText() ? 'true' : 'false') . ";\n\tViewMessage.HasPlain = " . ($message->HasPlainText() ? 'true' : 'false') . ";\n\tViewMessage.Importance = " . $message->GetPriorityStatus() . ";\n\tViewMessage.Sensivity = " . $message->GetSensitivity() . ";\n\tViewMessage.Charset = " . $mes_charset . ";\n\tViewMessage.HasCharset = " . ($message->HasCharset ? 'true' : 'false') . ";\n\tViewMessage.RTL = " . ($isRTL ? 'true' : 'false') . ";\n\tViewMessage.Safety = " . (int) $safety . ";\n\tViewMessage.Downloaded = " . ($message->Downloaded ? 'true' : 'false') . ";\n\tViewMessage.FromAddr = '" . ConvertUtils::ReBuildStringToJavaScript($from4search->ToDecodedString(), '\'') . "';\n\tViewMessage.FromDisplayName = '" . ConvertUtils::ReBuildStringToJavaScript(WebMailMessage::ClearForSend(trim($from4search->DisplayName)), '\'') . "';\n\tViewMessage.ToAddr = '" . ConvertUtils::ReBuildStringToJavaScript($message->GetToAsString(true), '\'') . "';\n\tViewMessage.ShortToAddr = '" . ConvertUtils::ReBuildStringToJavaScript($message->GetToAsString(true), '\'') . "';\n\tViewMessage.CCAddr = '" . ConvertUtils::ReBuildStringToJavaScript($message->GetCcAsString(true), '\'') . "';\n\tViewMessage.BCCAddr = '" . ConvertUtils::ReBuildStringToJavaScript($message->GetBccAsString(true), '\'') . "';\n\tViewMessage.ReplyToAddr = '" . ConvertUtils::ReBuildStringToJavaScript($message->GetReplyToAsString(true), '\'') . "';\n\tViewMessage.Subject = '" . ConvertUtils::ReBuildStringToJavaScript($message->GetSubject(true), '\'') . "';\n\tViewMessage.Date = '" . ConvertUtils::ReBuildStringToJavaScript($date->GetFormattedShortDate($accountOffset), '\'') . "';\n\tViewMessage.FullDate = '" . ConvertUtils::ReBuildStringToJavaScript($date->GetFormattedFullDate($accountOffset), '\'') . "';\n\tViewMessage.Time = '" . ConvertUtils::ReBuildStringToJavaScript($date->GetFormattedTime($accountOffset), '\'') . "';\n\tViewMessage.HtmlBody = '" . ConvertUtils::ReBuildStringToJavaScript($HtmlBody, '\'') . "';\n\tViewMessage.PlainBody = '" . ConvertUtils::ReBuildStringToJavaScript($PlainBody, '\'') . "';\n\tViewMessage.ClearPlainBody = '" . ConvertUtils::ReBuildStringToJavaScript($PlainBody, '\'') . "';\n\tViewMessage.SaveLink = '" . ConvertUtils::ReBuildStringToJavaScript('attach.php?' . $_msqAttachLine, '\'') . "';\n\tViewMessage.PrintLink = '" . ConvertUtils::ReBuildStringToJavaScript('message-view.php?type=' . MESSAGE_VIEW_TYPE_PRINT . '&' . $_msqAttachLine . '&charset=' . $mes_charset, '\'') . "';\n\tViewMessage.Attachments = [];"; foreach ($addAttachArray as $attachItem) { echo ' ViewMessage.Attachments.push({ Id: -1, Inline: ' . ($attachItem['inline'] ? 'true' : 'false') . ', Size: ' . $attachItem['size'] . ', MimeType: "' . ConvertUtils::ReBuildStringToJavaScript($attachItem['mime_type'], '"') . '", FileName: "' . ConvertUtils::ReBuildStringToJavaScript($attachItem['filename'], '"') . '", Download: "' . ConvertUtils::ReBuildStringToJavaScript($attachItem['download'], '"') . '", View: "' . ConvertUtils::ReBuildStringToJavaScript($attachItem['view'], '"') . '", TempName: "' . ConvertUtils::ReBuildStringToJavaScript($attachItem['tempname'], '"') . '" });' . "\r\n"; } $_signature_html = ''; $_signature_plain = ''; if ($account->SignatureOptions == SIGNATURE_OPTION_AddToAll) { if ($account->SignatureType == 1) { $_signature_html = '<br />' . $account->Signature;
/** * @param Account $account * @param array $to * @param string $subject * @param string $bodyText * @param bool $isBodyHtml = false * @param array $attachmentsFileName = array() * @return bool */ protected function _SendMessage($account, $to, $subject, $bodyText, $isBodyHtml = false, $attachmentsFileName = array()) { require_once WM_ROOTPATH . 'common/class_settings.php'; require_once WM_ROOTPATH . 'common/class_account.php'; require_once WM_ROOTPATH . 'common/class_webmailmessages.php'; require_once WM_ROOTPATH . 'common/class_smtp.php'; $settings =& Settings::CreateInstance(); if (!$settings || !$settings->isLoad) { throw new WebMailModelException('settings error'); } if (!$settings->IncludeLang()) { throw new WebMailModelException('lang error'); } $message = new WebMailMessage(); $GLOBALS[MailDefaultCharset] = $account->GetUserCharset(); $GLOBALS[MailInputCharset] = $account->GetUserCharset(); $GLOBALS[MailOutputCharset] = $account->GetDefaultOutCharset(); $message->Headers->SetHeaderByName(MIMEConst_MimeVersion, '1.0'); $message->Headers->SetHeaderByName(MIMEConst_XMailer, XMAILERHEADERVALUE); $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null; if (null !== $ip) { $message->Headers->SetHeaderByName(MIMEConst_XOriginatingIp, $ip); } $message->IdMsg = -1; $message->Uid = -1; $_serverAddr = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['SERVER_NAME'] : 'cantgetservername'; $message->Headers->SetHeaderByName(MIMEConst_MessageID, '<' . substr(session_id(), 0, 7) . '.' . md5(time()) . '@' . $_serverAddr . '>'); $message->SetFromAsString($account->GetFriendlyEmail()); $message->SetToAsString(implode(', ', $to)); $message->SetSubject($subject); $message->SetDate(new CDateTime(time())); if ($isBodyHtml) { $message->TextBodies->HtmlTextBodyPart = ConvertUtils::AddHtmlTagToHtmlBody(str_replace("\n", CRLF, str_replace("\r", '', ConvertUtils::WMBackHtmlNewCode($bodyText)))); } else { $message->TextBodies->PlainTextBodyPart = str_replace("\n", CRLF, str_replace("\r", '', ConvertUtils::WMBackHtmlNewCode($bodyText))); } if (count($attachmentsFileName) > 0) { foreach ($attachmentsFileName as $attachmentFileName) { $message->Attachments->AddFromFile($attachmentFileName, basename($attachmentFileName), ConvertUtils::GetContentTypeFromFileName(basename($attachmentFileName))); } } $message->OriginalMailMessage = $message->ToMailString(true); $message->Flags |= MESSAGEFLAGS_Seen; return CSmtp::SendMail($settings, $account, $message, $account->GetFriendlyEmail(), implode(', ', $to)); }
/** * @param WebMailMessage $message * @param string $AccountId * @return string */ function SaveBody(&$message, $accountId) { //save body $sql = 'INSERT INTO %sawm_messages_body (id_acct, id_msg, msg) VALUES (%d, %d, %s)'; return sprintf($sql, $this->_settings->DbPrefix, $accountId, $message->IdMsg, "0x" . bin2hex($message->TryToGetOriginalMailMessage())); }
/** * @param WebMailMessage $message * @param Folder $folder * @return bool */ function SaveMessage(&$message, &$folder, $fromFolder = null) { if ($message == null || $folder == null) { return false; } //Get size all messages in DB $mailBoxesSize = $this->DbStorage->SelectMailboxesSize() + $message->GetMailSize(); $this->DbStorage->SelectMailboxesSize(); if ($this->MailStorage->_settings->EnableMailboxSizeLimit && $this->_account->MailboxLimit < $mailBoxesSize) { setGlobalError(ErrorGetMailLimit); return false; } switch ($this->_account->MailProtocol) { case MAILPROTOCOL_POP3: $result = true; if ($this->DbStorage->Connect()) { //if ($message->IdMsg != -1) //{ //$messageIdSet = array($message->IdMsg); //$result &= $this->DbStorage->DeleteMessages($messageIdSet, false, $folder); //} //else //{ $message->IdMsg = $this->DbStorage->SelectLastIdMsg() + 1; //} return $result && $this->DbStorage->SaveMessage($message, $folder); } case MAILPROTOCOL_IMAP4: $result = true; if ($message->IdMsg != -1) { $messageIdUidSet = array(); $messageIdUidSet[$message->IdMsg] = $message->Uid; $nfolder = $fromFolder ? $fromFolder : $folder; $result &= $this->DeleteMessages($messageIdUidSet, $nfolder); } if ($folder->SyncType != FOLDERSYNC_DontSync) { if ($this->MailStorage->Connect()) { $result &= $this->MailStorage->SaveMessage($message, $folder); $GLOBALS[MailDefaultCharset] = $this->_account->GetDefaultIncCharset(); unset($GLOBALS[MailInputCharset]); $GLOBALS[MailOutputCharset] = $this->_account->GetUserCharset(); $result &= $this->MailStorage->SynchronizeFolder($folder); } return $result; } elseif ($this->DbStorage->Connect()) { //if ($message->IdMsg == -1) //{ $message->IdMsg = $this->DbStorage->SelectLastIdMsg() + 1; //} $result &= $this->DbStorage->SaveMessage($message, $folder); return $result; } case MAILPROTOCOL_WMSERVER: $result = true; if ($this->DbStorage->Connect()) { $message->IdMsg = $this->DbStorage->SelectLastIdMsg() + 1; return $result && $this->DbStorage->SaveMessage($message, $folder); } } return false; }
/** * @param WebMailMessage $message * @param string $accountId * @return string */ function UpdateBody(&$message, $accountId) { $sql = 'UPDATE %sawm_messages_body SET msg = %s WHERE id_acct = %d AND id_msg = %d'; return sprintf($sql, $this->_settings->DbPrefix, $this->_escapeBin($message->TryToGetOriginalMailMessage()), $accountId, $message->IdMsg); }