note 69932 modified in function.mail by danbrown

From: Date: Sat, 25 Apr 2009 15:00:49 +0000
Subject: note 69932 modified in function.mail by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-153739@lists.php.net to get a copy of this message
[EDITOR's NOTE: Following based off of a note originally by marcelo dot maraboli at usm dot cl which has been removed.] I had a trouble with marcelo' function, I had to add "$val == 63" condition into "if" sentence for '?' character <?php # From marcelo post: function encode_iso88591($string) { $text = '=?iso-8859-1?q?'; for( $i = 0 ; $i < strlen($string) ; $i++ ) { $val = ord($string[$i]); if($val > 127 or $val == 63) { $val = dechex($val); $text .= '='.$val; } else { $text .= $string[$i]; } } $text .= '?='; return $text; } and later use: // create email $msg = wordwrap($msg, 70); $to = "destination@company.com"; $subject = encode_iso88591("hoydía caminé !!"); $headers = "MIME-Versin: 1.0\r\n" . "Content-type: text/plain; charset=ISO-8859-1; format=flowed\r\n" . "Content-Transfer-Encoding: 8bit\r\n" . "From: $from\r\n" . "X-Mailer: PHP" . phpversion(); mail($to, $subject, $msg, $headers); ?> --was-- [EDITOR's NOTE: Following based off of a note originally by marcelo dot maraboli at usm dot cl which has been removed.] I had a trouble with marcelo' function, I had to add "$val == 63" condition into "if" sentence for '?' character # From marcelo post: function encode_iso88591($string) { $text = '=?iso-8859-1?q?'; for( $i = 0 ; $i < strlen($string) ; $i++ ) { $val = ord($string[$i]); if($val > 127 or $val == 63) { $val = dechex($val); $text .= '='.$val; } else { $text .= $string[$i]; } } $text .= '?='; return $text; } and later use: // create email $msg = wordwrap($msg, 70); $to = "destination@company.com"; $subject = encode_iso88591("hoydía caminé !!"); $headers = "MIME-Versin: 1.0\r\n" . "Content-type: text/plain; charset=ISO-8859-1; format=flowed\r\n" . "Content-Transfer-Encoding: 8bit\r\n" . "From: $from\r\n" . "X-Mailer: PHP" . phpversion(); mail($to, $subject, $msg, $headers); http://php.net/manual/en/function.mail.php

« previous php.notes (#153739) next »