all right folks...
here is the "gotcha" problem:
after series of fsockopen() in my pop3 server, i got using "TOP n 0", the headers, and using a trick:
<?
$fp = fsockopen("pop3.uol.com.br",110);
$uns = fgets($fp,1024);
fputs($fp,"USER paulo.ruthes\n");
$uns = fgets($fp,1024);
fputs($fp,"PASS xxxx\n");
$uns = fgets($fp,1024);
// here comes the trick to read MSG 1 w/o deleting it.
fputs($fp,"TOP 1 0\n");
while (($linha = fgets($fp,1024)) != ".".chr(13).chr(10)) {
$cont++;
}
fputs($fp,"TOP 1 100000000000\n"); // using TOP n N - it will get N lines after the headers
while (($linha = fgets($fp,1024)) != ".".chr(13).chr(10)) {
$cont_2++;
if ($cont_2<=$cont) {
}
else {
echo $linha . "<br>";
}
}
?>
ok, so it will only print the BODY of the email right? so... it comes usually QUOTED-PRINTABLE, using this function:
<?
function arrumar($linha) {
if (ereg("\?iso\-8859\-1\?Q\?",$linha)) {
$linha = str_replace("?iso-8859-1?Q?","",$linha);
$linha = str_replace("_"," ",$linha);
}
$linha = str_replace("=5B", "[", $linha);
$linha = str_replace("=3A", ":", $linha);
$linha = str_replace("=5D", "]", $linha);
$linha = str_replace("=FA", "ú", $linha);
$linha = str_replace("=5F", "_", $linha);
$linha = str_replace("=28", "(", $linha);
$linha = str_replace("=29", ")", $linha);
$linha = str_replace("=E6", "æ", $linha);
$linha = str_replace("=F8", "ø", $linha);
$linha = str_replace("=E5", "å", $linha);
$linha = str_replace("=C6", "Æ", $linha);
$linha = str_replace("=D8", "Ø", $linha);
$linha = str_replace("=C5", "Å", $linha);
$linha = str_replace("=A7", "§", $linha);
$linha = str_replace("=A4", "¤", $linha);
$linha = str_replace("=3D", "(%)", $linha);
$linha = str_replace("=20", " ", $linha);
$linha = str_replace("=A3", "£", $linha);
$linha = str_replace("=E4", "ä", $linha);
$linha = str_replace("=F6", "ö", $linha);
$linha = str_replace("=C4", "Ä", $linha);
$linha = str_replace("=D6", "Ö", $linha);
$linha = str_replace("=E7", "ç", $linha);
$linha = str_replace("=E3", "ã", $linha);
$linha = str_replace("=3D", "=", $linha);
$linha = str_replace("=EA", "ê", $linha);
$linha = str_replace("=E1", "á", $linha);
$linha = str_replace("=E9", "é", $linha);
$linha = str_replace("=F5", "õ", $linha);
$linha = str_replace("=F3", "ó", $linha);
$linha = str_replace("=ED", "í", $linha);
$linha = str_replace("=B4", "'", $linha);
$linha = str_replace("=", "", $linha);
$linha = str_replace("\n", "", $linha);
$linha = str_replace("(%)", "=", $linha);
return trim($linha);
}
?>
if you read it, you'll realize that I replace first =3D to %, so after I replace all equal signs to nothing, and replace (%) to =. BUT, even using trim(), some word appear broken with that damn space character...
so... if anyone could help me... plez.. email-me
[]'s
Paulo Vitto Ruthes
paulo.ruthes@uol.com.br
ICQ#18058144