note 86685 added to function.imap-fetchstructure
| From: | RuiTorrerui_sharkye at hotmail dot com | Date: | Wed, 29 Oct 2008 18:38:42 +0000 |
| Subject: | note 86685 added to function.imap-fetchstructure | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-145945@lists.php.net to get a copy of this message | ||
I'm programing an webmail program and trying to make the less code possible, so I've made
this function to get all mail parts
Hope it helps someone or if you manage to improve this function please post me.
$caixa_mail = @imap_open ("{localhost:143/notls}INBOX", $user, $password) or die ("It
was not possible to establish the imap connection.");
$uid_msg = 1;
$partes_mensagem = obter_partes($caixa_mail, $uid_msg);
function obter_partes($imap, $uid, $estrutura = false, $nparte = 1){
if (!$estrutura){ $estrutura = imap_fetchstructure($imap, $uid, FT_UID);}
//This shows the headers part number (I need to work a little more on this part)
if ($estrutura->parts > 0){
$decimas = explode(".", $nparte);
$decimas[count($decimas)-1] -= 1;
$np = implode(".", $decimas);
} else {
$np = $nparte;
}
//Its a possible message parte (plain or html)
if ($estrutura->type == 0){ print "> mensagem: ";}
print "$np - ".$estrutura->subtype."<br>";
if (count($estrutura->parts) > 0){
foreach ($estrutura->parts as $n => $parte){
if ($n >= 1){
$arr_decimas = explode(".", $nparte);
$arr_decimas[count($arr_decimas)-1] += 1;
$nparte = implode(".", $arr_decimas);
}
if ($parte->type != 1){
if ($parte->type == 0){ print "mensagem: ";}
print "$nparte - ".$parte->subtype."<br>";
}
if (count($parte->parts) > 0){
if ($parte->type == 1){
obter_partes($imap, $uid, $parte, $nparte.".".($n+1));
} else {
foreach ($parte->parts as $idx => $prt){
obter_partes($imap, $uid, $prt, $nparte.".".($idx+1));
}
}
}
}
}
}
----
Server IP: 81.92.192.129
Probable Submitter: 87.196.166.18
----
Manual Page -- http://www.php.net/manual/en/function.imap-fetchstructure.php
Edit -- https://master.php.net/note/edit/86685
Del: integrated -- https://master.php.net/note/delete/86685/integrated
Del: useless -- https://master.php.net/note/delete/86685/useless
Del: bad code -- https://master.php.net/note/delete/86685/bad+code
Del: spam -- https://master.php.net/note/delete/86685/spam
Del: non-english -- https://master.php.net/note/delete/86685/non-english
Del: in docs -- https://master.php.net/note/delete/86685/in+docs
Del: other reasons-- https://master.php.net/note/delete/86685
Reject -- https://master.php.net/note/reject/86685
Search -- https://master.php.net/manage/user-notes.php