note 69932 deleted from function.mail by danbrown
| From: | danbrown@php.net | Date: | Mon, 20 Jun 2011 15:12:38 +0000 |
| Subject: | note 69932 deleted from function.mail by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-180721@lists.php.net to get a copy of this message | ||
Note Submitter: i5513
----
[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);
?>