public static function encode($text, $eol = "\n", $wrap = 76)
    {
        $fp = fopen('php://temp', 'r+');
        stream_filter_append(
            $fp,
            'convert.quoted-printable-encode',
            STREAM_FILTER_WRITE,
            array(
                'line-break-chars' => $eol,
                'line-length' => $wrap
            )
        );
        fwrite($fp, $text);
        rewind($fp);
        $out = stream_get_contents($fp);
        fclose($fp);

        return $out;
    }