Example #1
0
 /**
  * @param string $str
  * @param string $encoding
  * @param string $charset
  *
  * @return string
  */
 public function decodeString($str, $encoding, $charset, $isHeader = true)
 {
     switch (strtolower($encoding)) {
         case "base64":
             $str = base64_decode($str);
             break;
         case "quoted-printable":
             $str = Sabel_Mail_QuotedPrintable::decode($str, $isHeader);
             break;
     }
     if ($this->isMbstringLoaded && $charset) {
         return $this->mbConvertEncoding($str, $charset);
     } else {
         return $str;
     }
 }
Example #2
0
 protected function encode($str, $encoding, $eol = "\r\n", $length = Sabel_Mail::LINELENGTH)
 {
     switch (strtolower($encoding)) {
         case "base64":
             return rtrim(chunk_split(base64_encode($str), $length, $eol));
         case "quoted-printable":
             return Sabel_Mail_QuotedPrintable::encode($str, $length, $eol);
         default:
             return $str;
     }
 }
Example #3
0
 public function encodeHeader($header)
 {
     if ($this->isMbstringLoaded) {
         $enc = $this->headerEncoding === "base64" ? "B" : "Q";
         return mb_encode_mimeheader($header, $this->charset, $enc, self::$EOL);
     } elseif ($this->headerEncoding === "base64") {
         return "=?{$this->charset}?B?" . base64_encode($header) . "?=";
     } else {
         $quoted = Sabel_Mail_QuotedPrintable::encode($header, self::LINELENGTH, self::$EOL);
         return "=?{$this->charset}?Q?{$quoted}?=";
     }
 }