setHeaderCharset() 공개 메소드

Set the character set to use when outputting MIME headers.
public setHeaderCharset ( string $charset )
$charset string The character set.
예제 #1
0
파일: PublicKey.php 프로젝트: horde/horde
 /**
  * Generates a Horde_Mime_Part object, in accordance with RFC 3156, that
  * contains a public key.
  *
  * @return Horde_Mime_Part  Object that contains the armored public key.
  */
 public function createMimePart()
 {
     $part = new Horde_Mime_Part();
     $part->setType('application/pgp-keys');
     $part->setHeaderCharset('UTF-8');
     $part->setDescription(Horde_Pgp_Translation::t("PGP Public Key"));
     $part->setContents(strval($this), array('encoding' => '7bit'));
     return $part;
 }
예제 #2
0
파일: Mime.php 프로젝트: horde/horde
 /**
  * Generate a Horde_Mime_Part object that contains a public key (RFC
  * 3156 [7]).
  *
  * @param mixed $key  The public key.
  *
  * @return Horde_Mime_Part  An object that contains the public key.
  */
 public function publicKeyPart($key)
 {
     $key = Horde_Pgp_Element_PublicKey::create($key);
     $part = new Horde_Mime_Part();
     $part->setType('application/pgp-keys');
     $part->setHeaderCharset('UTF-8');
     $part->setDescription(Horde_Crypt_Translation::t("PGP Public Key"));
     $part->setContents(strval($key), array('encoding' => '7bit'));
     return $part;
 }
예제 #3
0
파일: Pgp.php 프로젝트: horde/horde
 /**
  * Generates a Horde_Mime_Part object, in accordance with RFC 3156, that
  * contains a public key.
  *
  * @param string $key  The public key.
  *
  * @return Horde_Mime_Part  An object that contains the public key.
  */
 public function publicKeyMIMEPart($key)
 {
     $part = new Horde_Mime_Part();
     $part->setType('application/pgp-keys');
     $part->setHeaderCharset('UTF-8');
     $part->setDescription(Horde_Crypt_Translation::t("PGP Public Key"));
     $part->setContents($key, array('encoding' => '7bit'));
     return $part;
 }
예제 #4
0
파일: Smime.php 프로젝트: jubinpatel/horde
 /**
  * Encrypt a MIME part using S/MIME. This produces S/MIME Version 3.2
  * compatible data (see RFC 5751 [3.3]).
  *
  * @param Horde_Mime_Part $mime_part  The object to encrypt.
  * @param array $params               The parameters required for
  *                                    encryption.
  *
  * @return Horde_Mime_Part  An encrypted MIME part object.
  * @throws Horde_Crypt_Exception
  */
 public function encryptMIMEPart($mime_part, $params = array())
 {
     /* Sign the part as a message */
     $message = $this->encrypt($mime_part->toString(array('headers' => true, 'canonical' => true)), $params);
     $msg = new Horde_Mime_Part();
     $msg->setCharset($this->_params['email_charset']);
     $msg->setHeaderCharset('UTF-8');
     $msg->setDescription(Horde_Crypt_Translation::t("S/MIME Encrypted Message"));
     $msg->setDisposition('inline');
     $msg->setType('application/pkcs7-mime');
     $msg->setContentTypeParameter('smime-type', 'enveloped-data');
     $msg->setContents(substr($message, strpos($message, "\n\n") + 2), array('encoding' => 'base64'));
     return $msg;
 }
예제 #5
0
파일: Compose.php 프로젝트: raz0rsdge/horde
 /**
  * Adds an attachment to the outgoing compose message.
  *
  * @param string $atc_file  Temporary file containing attachment contents.
  * @param integer $bytes    Size of data, in bytes.
  * @param string $filename  Filename of data.
  * @param string $type      MIME type of data.
  *
  * @return IMP_Compose_Attachment  Attachment object.
  * @throws IMP_Compose_Exception
  */
 protected function _addAttachment($atc_file, $bytes, $filename, $type)
 {
     global $conf, $injector;
     $atc = new Horde_Mime_Part();
     $atc->setBytes($bytes);
     /* Try to determine the MIME type from 1) the extension and
      * then 2) analysis of the file (if available). */
     if (strlen($filename)) {
         $atc->setName($filename);
         if ($type == 'application/octet-stream') {
             $type = Horde_Mime_Magic::filenameToMIME($filename, false);
         }
     }
     $atc->setType($type);
     if ($atc->getType() == 'application/octet-stream' || $atc->getPrimaryType() == 'text') {
         $analyze = Horde_Mime_Magic::analyzeFile($atc_file, empty($conf['mime']['magic_db']) ? null : $conf['mime']['magic_db'], array('nostrip' => true));
         $atc->setCharset('UTF-8');
         if ($analyze) {
             $ctype = new Horde_Mime_Headers_ContentParam('Content-Type', $analyze);
             $atc->setType($ctype->value);
             if (isset($ctype->params['charset'])) {
                 $atc->setCharset($ctype->params['charset']);
             }
         }
     } else {
         $atc->setHeaderCharset('UTF-8');
     }
     $atc_ob = new IMP_Compose_Attachment($this, $atc, $atc_file);
     /* Check for attachment size limitations. */
     $size_limit = null;
     if ($atc_ob->linked) {
         if (!empty($conf['compose']['link_attach_size_limit'])) {
             $linked = true;
             $size_limit = 'link_attach_size_limit';
         }
     } elseif (!empty($conf['compose']['attach_size_limit'])) {
         $linked = false;
         $size_limit = 'attach_size_limit';
     }
     if (!is_null($size_limit)) {
         $total_size = $conf['compose'][$size_limit] - $bytes;
         foreach ($this as $val) {
             if ($val->linked == $linked) {
                 $total_size -= $val->getPart()->getBytes();
             }
         }
         if ($total_size < 0) {
             throw new IMP_Compose_Exception(strlen($filename) ? sprintf(_("Attached file \"%s\" exceeds the attachment size limits. File NOT attached."), $filename) : _("Attached file exceeds the attachment size limits. File NOT attached."));
         }
     }
     try {
         $injector->getInstance('Horde_Core_Hooks')->callHook('compose_attachment', 'imp', array($atc_ob));
     } catch (Horde_Exception_HookNotSet $e) {
     }
     $this->_atc[$atc_ob->id] = $atc_ob;
     $this->changed = 'changed';
     return $atc_ob;
 }