Ejemplo n.º 1
0
 /**
  * @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]);
     }
 }
Ejemplo n.º 2
0
 /**
  * @return bool
  */
 function IsMimePartTextBody()
 {
     if ($this->Headers == null || $this->Headers->Count() == 0) {
         return true;
     }
     $contType = strtolower($this->GetContentType());
     $contDist = $this->GetDisposition();
     if (!$contType) {
         return false;
     }
     $contentTypeHeader = new HeaderParameterCollection($contType);
     $contentDispositionHeader = $contDist ? new HeaderParameterCollection($contDist) : null;
     if ($contentDispositionHeader) {
         $attach = $contentDispositionHeader->GetByName(MIMEConst_AttachmentLower);
         $filename = $contentDispositionHeader->GetByName(MIMEConst_FilenameLower);
     } else {
         $attach = $filename = null;
     }
     $name = $contentTypeHeader ? $contentTypeHeader->GetByName(MIMEConst_NameLower) : null;
     if ($attach != null || $filename != null || $name != null) {
         return false;
     }
     $filenameVal = $filename ? $filename->Value : '';
     $nameVal = $name ? $name->Value : '';
     if (strlen($filenameVal) != 0 || strlen($nameVal) != 0) {
         return false;
     }
     if (strpos($contType, MIMETypeConst_TextHtml) !== false || strpos($contType, MIMETypeConst_TextPlain) !== false) {
         return true;
     }
     return false;
 }
Ejemplo n.º 3
0
 /**
  * @return string
  */
 function GetBoundary()
 {
     $contentTypeHeader =& $this->Headers->GetHeaderByName(MIMEConst_ContentTypeLower);
     if ($contentTypeHeader != null) {
         $headerParameters = new HeaderParameterCollection($contentTypeHeader->Value);
         $param = $headerParameters->GetByName(MIMEConst_BoundaryLower);
         if ($param != null) {
             return $param->Value;
         }
     }
     return '';
 }