noMimeMessage = self::DEFAULT_NO_MIME_MESSAGE; $this->boundary = $this->generateBoundary(); $this->setHeader( "Content-Type", 'multipart/' . $this->multipartType() . '; ' . 'boundary="' . $this->boundary . '"' ); foreach ( $parts as $part ) { if ( $part instanceof ezcMailPart ) { $this->parts[] = $part; } elseif( is_array( $part ) ) // add each and everyone of the parts in the array { foreach ( $part as $array_part ) { if ( $array_part instanceof ezcMailPart ) { $this->parts[] = $array_part;; } } } } } /** * Sets the property $name to $value. * * @throws ezcBasePropertyNotFoundException * if the property does not exist. * @param string $name * @param mixed $value * @ignore */ public function __set( $name, $value ) { switch ( $name ) { case 'boundary': $this->properties[$name] = $value; $this->setHeader( 'Content-Type', 'multipart/' . $this->multipartType() . '; ' . 'boundary="' . $this->boundary . '"' ); break; case 'noMimeMessage': $this->properties[$name] = $value; break; default: return parent::__set( $name, $value ); break; } } /** * Returns the property $name. * * @throws ezcBasePropertyNotFoundException * if the property does not exist. * @param string $name * @return mixed * @ignore */ public function __get( $name ) { switch ( $name ) { case 'boundary': case 'noMimeMessage': return $this->properties[$name]; break; default: return parent::__get( $name ); break; } } /** * Returns true if the property $name is set, otherwise false. * * @param string $name * @return bool * @ignore */ public function __isset( $name ) { switch ( $name ) { case 'boundary': case 'noMimeMessage': return isset( $this->properties[$name] ); default: return parent::__isset( $name ); } } /** * Returns the generated body for all multipart types. * * @return string */ public function generateBody() { $data = $this->noMimeMessage . ezcMailTools::lineBreak(); foreach ( $this->parts as $part ) { $data .= ezcMailTools::lineBreak() . '--' . $this->boundary . ezcMailTools::lineBreak(); $data .= $part->generate(); } $data .= ezcMailTools::lineBreak() . '--' . $this->boundary . '--'; return $data; } /** * Returns the type of multipart. * * @return string */ abstract public function multipartType(); /** * Returns a unique boundary string. * * @return string */ protected static function generateBoundary() { return date( "YmdGHjs" ) . ':' . getmypid() . ':' . self::$counter++; } } ?>