1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
function open_mailbox($servername, $userlogin, $userpassword) {
$imaphost = "{".$servername.":143"."}"."INBOX";
// $imaphost = "{".$servername.":143"."}"."INBOX";
$imapmsgbox = imap_open($imaphost, $userlogin, $userpassword);
return $imapmsgbox;
}
function status_mailbox($mbox,$servername)
{
$host = "{".$servername.":143"."}"."INBOX";
$status = imap_status($mbox, $host, SA_ALL);
if(!$status) {
echo "imap_status a échoué : " . imap_last_error() . "\n";
}
return $status;
}
function decode_mail($mbox, $msg){
$obj = imap_fetchstructure($mbox, $msg, FT_UID); $moet_werken=true; $id=1;
while($moet_werken){
$attachments = Check_Part($obj, $id);
$moet_werken=false;
}
return $attachments;
}
function Check_Part($part,$id){
switch($part->type){
case 1: if((strtolower($part->subtype) == "mixed")
or (strtolower($part->subtype) == "alternative")
or (strtolower($part->subtype) == "related")) break;
default: $an = sizeof($attachments);
if($part->ifdparameters){
$dpara = $part->dparameters;
for ($v=0;$v<sizeof($dpara);$v++){
if (eregi("filename", $dpara[$v]->attribute))
$fname = $dpara[$v]->value;}
}
if($part->ifparameters){
if(empty($fname)){
$para = $part->parameters;
for ($v=0;$v<sizeof($para);$v++){
if (eregi("name", $para[$v]->attribute)) $fname = $para[$v]->value;
}
}
}
if(empty($fname))$fname = "(no name)";
$attachments[$an]->id = ($an+1);
$attachments[$an]->part = $id;
$attachments[$an]->filename = $fname;
$attachments[$an]->type = $part->type;
$attachments[$an]->subtype = $part->subtype;
$attachments[$an]->dispos = $dispos;
$attachments[$an]->size = $part->bytes;
$attachments[$an]->encod = $part->encoding;
break;
}
for($x = 0; $x < count($part->parts); $x++){
$attachments = Check_Part($part->parts[$x], $id.".".($x+1));
}
return $attachments;
} |
Partager