/** * @param MimePart $mimePart */ function AddToCollection(&$mimePart, $force = false) { if ($force || $mimePart->IsMimePartTextBody()) { if ($mimePart->IsMimePartAttachment()) { return; } $contentType = strtolower($mimePart->GetContentType()); $charset = new HeaderParameterCollection($contentType); $charset = $charset->GetByName(MIMEConst_CharsetLower); $contentCharset = $charset ? $charset->Value : ''; if ($GLOBALS[MailInputCharset] === '') { $GLOBALS[MailInputCharset] = $contentCharset; $this->HasCharset = $contentCharset; if (null === $this->_charset) { $this->_charset = $contentCharset; } } else { if (null === $this->_charset) { $this->_charset = $GLOBALS[MailInputCharset]; } } if (strpos($contentType, MIMETypeConst_TextPlain) !== false || $contentType === '') { $this->PlainTextBodyPart .= trim($mimePart->GetBody(MIMEConst_TrimBodyLen_Bytes)); } else { if (strpos($contentType, MIMETypeConst_TextHtml) !== false) { $preStr = '/(<meta\\s.*)(charset\\s?=)([^"\'>\\s]*)/i'; $this->HtmlTextBodyPart .= trim(preg_replace($preStr, '$1$2' . $GLOBALS[MailOutputCharset], $mimePart->GetBody(MIMEConst_TrimBodyLen_Bytes))); } else { if ($force) { $this->PlainTextBodyPart .= trim($mimePart->GetBody(MIMEConst_TrimBodyLen_Bytes)); } } } } }
/** * @param MimePart $mimePart */ function SearchAttachParts(&$mimePart) { if ($mimePart->_subParts == null) { if ($mimePart->IsMimePartAttachment()) { $this->AddToCollection($mimePart); } } else { for ($i = 0, $c = $mimePart->_subParts->List->Count(); $i < $c; $i++) { $subPart =& $mimePart->_subParts->List->Get($i); $this->SearchAttachParts($subPart); } } }