note 106962 added to function.imap-fetchbody
| From: | arkop at hotmail dot fr | Date: | Wed, 21 Dec 2011 10:43:15 +0000 |
| Subject: | note 106962 added to function.imap-fetchbody | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-185192@lists.php.net to get a copy of this message | ||
Here is a function to display the accents well when retrieving the contents of an email (gmail) :
<?php
function ReplaceImap($txt) {
$carimap = array("=C3=A9", "=C3=A8", "=C3=AA", "=C3=AB",
"=C3=A7", "=C3=A0", "=20", "=C3=80", "=C3=89");
$carhtml = array("é", "è", "ê", "ë",
"ç", "à ", " ", "Ã", "Ã");
$txt = str_replace($carimap, $carhtml, $txt);
return $txt;
}
$mbox = imap_open("{imap.gmail.com:993/imap/ssl}INBOX", "login",
"pass");
$no = 5; // Mail to show (mail number)
$text = imap_fetchbody($mbox, $no, 1);
$text = imap_utf8($text);
$text = ReplaceImap($text);
$text = nl2br($text);
echo $text;
?>
I hope it will help ;)
(Sorry for my english, i'm french)
----
Server IP: 69.147.83.197
Probable Submitter: 92.161.86.40
----
Manual Page -- http://www.php.net/manual/en/function.imap-fetchbody.php
Edit -- https://master.php.net/note/edit/106962
Del: integrated -- https://master.php.net/note/delete/106962/integrated
Del: useless -- https://master.php.net/note/delete/106962/useless
Del: bad code -- https://master.php.net/note/delete/106962/bad+code
Del: spam -- https://master.php.net/note/delete/106962/spam
Del: non-english -- https://master.php.net/note/delete/106962/non-english
Del: in docs -- https://master.php.net/note/delete/106962/in+docs
Del: other reasons-- https://master.php.net/note/delete/106962
Reject -- https://master.php.net/note/reject/106962
Search -- https://master.php.net/manage/user-notes.php