/**
  * @param string $sBoundary
  *
  * @return resorce
  */
 public function ToStream($sBoundary)
 {
     $rResult = null;
     if (0 < \strlen($sBoundary)) {
         $aResult = array();
         $aParts =& $this->GetAsArray();
         foreach ($aParts as &$oPart) {
             if (0 < count($aResult)) {
                 $aResult[] = \MailSo\Mime\Enumerations\Constants::CRLF . '--' . $sBoundary . \MailSo\Mime\Enumerations\Constants::CRLF;
             }
             $aResult[] = $oPart->ToStream();
         }
         return \MailSo\Base\StreamWrappers\SubStreams::CreateStream($aResult);
     }
     return $rResult;
 }
Example #2
0
 /**
  * @return resorce
  */
 public function ToStream()
 {
     $this->Rewind();
     $aSubStreams = array($this->Headers->ToEncodedString() . \MailSo\Mime\Enumerations\Constants::CRLF . \MailSo\Mime\Enumerations\Constants::CRLF, null === $this->Body ? '' : $this->Body, \MailSo\Mime\Enumerations\Constants::CRLF);
     if (0 < $this->SubParts->Count()) {
         $sBoundary = $this->HeaderBoundary();
         if (0 < strlen($sBoundary)) {
             $aSubStreams[] = '--' . $sBoundary . \MailSo\Mime\Enumerations\Constants::CRLF;
             $rSubPartsStream = $this->SubParts->ToStream($sBoundary);
             if (is_resource($rSubPartsStream)) {
                 $aSubStreams[] = $rSubPartsStream;
             }
             $aSubStreams[] = \MailSo\Mime\Enumerations\Constants::CRLF . '--' . $sBoundary . '--' . \MailSo\Mime\Enumerations\Constants::CRLF;
         }
     }
     return \MailSo\Base\StreamWrappers\SubStreams::CreateStream($aSubStreams);
 }