|
From: Ben C. <php...@be...> - 2002-05-16 12:49:50
|
Would this cause issues with people who don't have mime-capable email
clients?
On Thu, May 16, 2002 at 03:37:39AM -0700, Jirka Pech wrote:
> Update of /cvsroot/phpbt/phpbt/inc
> In directory usw-pr-cvs1:/tmp/cvs-serv4123/phpbt/inc
>
> Modified Files:
> functions.php
> Log Message:
> Added qp_mail function (and one function, which helps with encoding) for outgoing mail handling. I will add some error handling for it later. Please, look on it and send your comments to dev-list.
>
>
> Index: functions.php
> ===================================================================
> RCS file: /cvsroot/phpbt/phpbt/inc/functions.php,v
> retrieving revision 1.22
> retrieving revision 1.23
> diff -u -r1.22 -r1.23
> --- functions.php 2 May 2002 13:17:57 -0000 1.22
> +++ functions.php 16 May 2002 10:37:37 -0000 1.23
> @@ -427,4 +427,46 @@
> return date($format, $string);
> }
>
> -?>
> +// quoted-printable encoder function
> +function qp_enc($input, $line_max = 76) {
> + $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
> + $lines = split("\n", str_replace("\r\n", "\n", $input));
> + $eol = "\n";
> + $escape = "=";
> + $output = "";
> + while( list(, $line) = each($lines) ) {
> + $line = rtrim($line);
> + $linlen = strlen($line);
> + $newline = "";
> + for($i = 0; $i < $linlen; $i++) {
> + $c = substr($line, $i, 1);
> + $dec = ord($c);
> + if ( ($dec == 32) && ($i == ($linlen - 1)) ) {
> + $c = "=20";
> + } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) {
> + $h2 = floor($dec/16); $h1 = floor($dec%16);
> + $c = $escape.$hex["$h2"].$hex["$h1"];
> + }
> + if ( (strlen($newline) + strlen($c)) >= $line_max ) {
> + $output .= $newline.$escape.$eol;
> + $newline = "";
> + }
> + $newline .= $c;
> + }
> + $output .= $newline.$eol;
> + }
> + return (trim($output));
> +}
> +
> +// mailer with use of quoted-printable encoding
> +function qp_mail($to, $subject = 'No subject', $body, $headers = '') {
> + global $STRING;
> +
> + if ($headers != '') {
> + $headers .= "\n";
> + // There have to be no newline at the end of $headers
> + }
> + $headers .= "Content-type: text/plain; charset=\"".$STRING['lang_charset']."\"\n";
> + $headers .= "Content-Transfer-Encoding: quoted-printable\nMIME-Version: 1.0";
> + mail ($to, $subject, qp_enc($body), $headers);
> +} ?>
> \ No newline at end of file
>
>
> _______________________________________________________________
>
> Have big pipes? SourceForge.net is looking for download mirrors. We supply
> the hardware. You get the recognition. Email Us: ban...@so...
> _______________________________________________
> phpbt-dev mailing list
> php...@li...
> https://lists.sourceforge.net/lists/listinfo/phpbt-dev
|