note 69830 added to function.mail

From: Date: Fri, 22 Sep 2006 13:36:45 +0000
Subject: note 69830 added to function.mail
Groups: php.notes 
Request: Send a blank email to php-notes+get-117424@lists.php.net to get a copy of this message
If you want to send accents (or special characters) in the subject, you must encode the string to a ISO-8859-1 format before sending the email. It is not enough just to add the Content-type header, because that's for encoding the content, not encoding the headers. Use this funtion: function encode_iso88591($string) { $text = '=?iso-8859-1?q?'; for( $i = 0 ; $i < strlen($string) ; $i++ ) { $val = ord($string[$i]); if($val > 127) { $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); ---- Server IP: 200.73.8.42 Probable Submitter: 200.1.21.50 ---- Manual Page -- http://www.php.net/manual/en/function.mail.php Edit -- https://master.php.net/note/edit/69830 Del: integrated -- https://master.php.net/note/delete/69830/integrated Del: useless -- https://master.php.net/note/delete/69830/useless Del: bad code -- https://master.php.net/note/delete/69830/bad+code Del: spam -- https://master.php.net/note/delete/69830/spam Del: non-english -- https://master.php.net/note/delete/69830/non-english Del: in docs -- https://master.php.net/note/delete/69830/in+docs Del: other reasons-- https://master.php.net/note/delete/69830 Reject -- https://master.php.net/note/reject/69830 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#117424) next »