/** * @return string */ function GetEncodedValue() { if ($this->IsParsed) { if ($this->IsEmailAddress()) { $addressCollection = new EmailAddressCollection($this->Value); return $addressCollection->ToString(); } if ($this->IsSubject()) { return ConvertUtils::EncodeHeaderString($this->Value, $GLOBALS[MailInputCharset], $GLOBALS[MailOutputCharset], true); } if ($this->IsWithParameters()) { $parameterCollection = new HeaderParameterCollection($this->Value); return $parameterCollection->ToString(true); } } if (ConvertUtils::IsLatin($this->Value)) { return $this->Value; } else { return ConvertUtils::EncodeHeaderString($this->Value, $GLOBALS[MailInputCharset], $GLOBALS[MailOutputCharset]); } }
/** * @param EmailAddressCollection $value */ function SetReplyTo($value) { $this->Headers->SetHeaderByName(MIMEConst_Bcc, $value->ToDecodedString()); }
/** * @return EmailAddressCollection */ function &GetAllRecipientsForReplyAll($accountEmailLower) { $emails = array(); $allRecipients = new EmailAddressCollection(); $toAddr =& $this->GetTo(); $toAddrKeys = array_keys($toAddr->Instance()); foreach ($toAddrKeys as $key) { $temp = $toAddr->Get($key); if ($temp && !in_array($temp->Email, $emails) && strtolower($temp->Email) != $accountEmailLower) { $emails[] = $temp->Email; $allRecipients->AddEmailAddress($temp); } unset($temp); } $ccAddr =& $this->GetCc(); $ccAddrKeys = array_keys($ccAddr->Instance()); foreach ($ccAddrKeys as $key) { $temp = $ccAddr->Get($key); if ($temp && !in_array($temp->Email, $emails)) { $emails[] = $temp->Email; $allRecipients->AddEmailAddress($temp); } unset($temp); } return $allRecipients; }
$oneGNode =& $gNode->Children[$key]; $gids[] = isset($oneGNode->Attributes['id']) ? (int) $oneGNode->Attributes['id'] : -1; } } } if ($toNode != null && $toNode->Value != null) { $emailsString .= ConvertUtils::WMBackHtmlSpecialChars($toNode->Value) . ', '; } if ($ccNode != null && $ccNode->Value != null) { $emailsString .= ConvertUtils::WMBackHtmlSpecialChars($ccNode->Value) . ', '; } if ($bccNode != null && $bccNode->Value != null) { $emailsString .= ConvertUtils::WMBackHtmlSpecialChars($bccNode->Value); } $emailsString = trim(trim($emailsString), ','); $emailsCollection = new EmailAddressCollection($emailsString); $arrEmails = array(); for ($l = 0; $l < $emailsCollection->Count(); $l++) { $emailObj =& $emailsCollection->Get($l); if (trim($emailObj->Email)) { $arrEmails[$emailObj->Email] = trim($emailObj->DisplayName); } } if (count($gids) > 0) { $processor->DbStorage->UpdateGroupsFrequency($gids); } $processor->DbStorage->UpdateSuggestTable($account, $arrEmails); //End suggestion if ($needToDelete) { $messageIdSet = array($idtoDelete); if ($account->MailProtocol == MAILPROTOCOL_IMAP4) {
function DoSendMessage() { $_dbStorage = $_settings = $_xmlObj = $_xmlRes = $_accountId = null; $this->_initFuncArgs($_dbStorage, $_settings, $_xmlObj, $_xmlRes, $_accountId); $_account =& CXmlProcessing::AccountCheckAndLoad($_xmlRes, $_accountId, false, false); $_message =& CXmlProcessing::CreateMessage($_account, $_xmlObj, $_xmlRes); /* custom class */ wm_Custom::StaticUseMethod('ChangeMessageBeforeSend', array(&$_message)); $_processor = new MailProcessor($_account); $_folders =& $_processor->GetFolders(); $_folder =& $_folders->GetFolderByType(FOLDERTYPE_SentItems); $_message->OriginalMailMessage = $_message->ToMailString(true); $_message->Flags |= MESSAGEFLAGS_Seen; $_from =& $_message->GetFrom(); $_result = true; $_needToDelete = $_message->IdMsg != -1; $_idtoDelete = $_message->IdMsg; if (CSmtp::SendMail($_settings, $_account, $_message, null, null)) { $_messageNode =& $_xmlObj->XmlRoot->GetChildNodeByTagName('message'); $_attachmentsNode =& $_messageNode->GetChildNodeByTagName('attachments'); $bSaveInSent = isset($_messageNode->Attributes['save_mail']) && 1 === (int) $_messageNode->Attributes['save_mail']; if ($_processor->DbStorage->Connect()) { $_draftsFolder = null; if ($_needToDelete) { $_draftsFolder =& $_folders->GetFolderByType(FOLDERTYPE_Drafts); if ($_draftsFolder) { if (!$_processor->SaveMessage($_message, $_folder, $_draftsFolder, !$bSaveInSent)) { $_needToDelete = false; } } } else { if ($bSaveInSent) { if (!$_processor->SaveMessage($_message, $_folder)) { $_needToDelete = false; } } } /* suggestion */ $_mNode =& $_xmlObj->XmlRoot->GetChildNodeByTagName('message'); $_hNode =& $_mNode->GetChildNodeByTagName('headers'); $_gNode =& $_hNode->GetChildNodeByTagName('groups'); $_toNode =& $_hNode->GetChildNodeByTagName('to'); $_ccNode =& $_hNode->GetChildNodeByTagName('cc'); $_bccNode =& $_hNode->GetChildNodeByTagName('bcc'); $_emailsString = ''; $_gids = array(); if ($_gNode != null && $_gNode->Value != null) { if (count($_gNode->Children) > 0) { $_gKeys = array_keys($_gNode->Children); foreach ($_gKeys as $_key) { $_oneGNode =& $_gNode->Children[$_key]; $_gids[] = isset($_oneGNode->Attributes['id']) ? (int) $_oneGNode->Attributes['id'] : -1; unset($_oneGNode); } } } if ($_toNode != null && $_toNode->Value != null) { $_emailsString .= ConvertUtils::WMBackHtmlSpecialChars($_toNode->Value) . ', '; } if ($_ccNode != null && $_ccNode->Value != null) { $_emailsString .= ConvertUtils::WMBackHtmlSpecialChars($_ccNode->Value) . ', '; } if ($_bccNode != null && $_bccNode->Value != null) { $_emailsString .= ConvertUtils::WMBackHtmlSpecialChars($_bccNode->Value); } $_emailsString = trim(trim($_emailsString), ','); $_emailsCollection = new EmailAddressCollection($_emailsString); $_arrEmails = array(); for ($_z = 0, $_lc = $_emailsCollection->Count(); $_z < $_lc; $_z++) { $_emailObj =& $_emailsCollection->Get($_z); if ($_emailObj && trim($_emailObj->Email)) { $_arrEmails[$_emailObj->Email] = trim($_emailObj->DisplayName); } } /* reply */ if (USE_DB) { CXmlProcessing::ReplySetFlag($_mNode, $_processor); } /* update group frequency */ if (USE_DB) { $_processor->DbStorage->UpdateGroupsFrequency($_gids); $_processor->DbStorage->UpdateSuggestTable($_account, $_arrEmails); } /* end suggestion */ if ($_needToDelete && $_draftsFolder) { $_messageIdSet = array($_idtoDelete); if ($_account->MailProtocol == MAILPROTOCOL_IMAP4) { if ($_processor->PurgeFolder($_draftsFolder) && USE_DB) { $_processor->DbStorage->DeleteMessages($_messageIdSet, false, $_draftsFolder); } } else { if (USE_DB) { $_processor->DbStorage->DeleteMessages($_messageIdSet, false, $_draftsFolder); } } } if (USE_DB) { $_processor->DbStorage->UpdateMailboxSize(); } } $_result = true; } else { $_result = false; } if ($_result) { $_updateNode = new XmlDomNode('update'); $_updateNode->AppendAttribute('value', 'send_message'); $_xmlRes->XmlRoot->AppendChild($_updateNode); } else { //CXmlProcessing::PrintErrorAndExit(getGlobalError(), $_xmlRes); CXmlProcessing::PrintErrorAndExit(PROC_CANT_SEND_MSG, $_xmlRes); } }
/** * @param EmailAddressCollection $recipients */ function AddEmailAddressCollection($recipients) { for ($i = 0; $i < $recipients->Count(); $i++) { $this->AddEmailAddress($recipients->Get($i)); } }