/**
  * Builds the multipart message.
  *
  * @param array    $params    Build parameters that change the way the email
  *                            is built. Should be associative. See $_build_params.
  * @param resource $filename  Output file where to save the message instead of
  *                            returning it
  * @param boolean  $skip_head True if you want to return/save only the message
  *                            without headers
  *
  * @return mixed The MIME message content string, null or PEAR error object
  */
 public function get($params = null, $filename = null, $skip_head = false)
 {
     if (isset($params)) {
         while (list($key, $value) = each($params)) {
             $this->build_params[$key] = $value;
         }
     }
     $this->checkParams();
     if ($this->type == self::PGP_SIGNED) {
         $params = array('preamble' => "This is an OpenPGP/MIME signed message (RFC 4880 and 3156)", 'content_type' => "multipart/signed; micalg=pgp-sha1; protocol=\"application/pgp-signature\"", 'eol' => $this->build_params['eol']);
         $message = new Mail_mimePart('', $params);
         if (!empty($this->body)) {
             $headers = $this->message->headers();
             $params = array('content_type' => $headers['Content-Type']);
             if ($headers['Content-Transfer-Encoding']) {
                 $params['encoding'] = $headers['Content-Transfer-Encoding'];
             }
             $message->addSubpart($this->body, $params);
         }
         if (!empty($this->signature)) {
             $message->addSubpart($this->signature, array('filename' => 'signature.asc', 'content_type' => 'application/pgp-signature', 'disposition' => 'attachment', 'description' => 'OpenPGP digital signature'));
         }
     } else {
         if ($this->type == self::PGP_ENCRYPTED) {
             $params = array('preamble' => "This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156)", 'content_type' => "multipart/encrypted; protocol=\"application/pgp-encrypted\"", 'eol' => $this->build_params['eol']);
             $message = new Mail_mimePart('', $params);
             $message->addSubpart('Version: 1', array('content_type' => 'application/pgp-encrypted', 'description' => 'PGP/MIME version identification'));
             $message->addSubpart($this->encrypted, array('content_type' => 'application/octet-stream', 'description' => 'PGP/MIME encrypted message', 'disposition' => 'inline', 'filename' => 'encrypted.asc'));
         }
     }
     // Use saved boundary
     if (!empty($this->build_params['boundary'])) {
         $boundary = $this->build_params['boundary'];
     } else {
         $boundary = null;
     }
     // Write output to file
     if ($filename) {
         // Append mimePart message headers and body into file
         $headers = $message->encodeToFile($filename, $boundary, $skip_head);
         if ($this->isError($headers)) {
             return $headers;
         }
         $this->headers = array_merge($this->headers, $headers);
         return null;
     } else {
         $output = $message->encode($boundary, $skip_head);
         if ($this->isError($output)) {
             return $output;
         }
         $this->headers = array_merge($this->headers, $output['headers']);
         return $output['body'];
     }
 }