Hallo
ich habe da eine Frage und zwar der folgende Code fragt doch das E-Mail Konto ab, ob die Mails einen Anhang haben?
in meinem Postfach habe ich eine Mail liegen und diese hat einen Anhang aber der Code gibt mir aus You don't have attachment(s).
Entweder habe ich jetzt den Code nicht verstanden oder da ist ein Fehler.
ich habe da eine Frage und zwar der folgende Code fragt doch das E-Mail Konto ab, ob die Mails einen Anhang haben?
PHP:
<?php
$msgnr = "1";
$folder ="INBOX";
$user = "user";
$passwd ="pw";
$con = imap_open ("{localhost/pop3:110}", $user, $passwd);
$est=imap_fetchstructure($con,$msg);
if(checkAttachments($est))
{
echo("You have attachment(s)");
}
else
{
echo("You don't have attachment(s)");
}
function checkAttachments($estMsg)
{
if(($estMsg->type!=0) && ($estMsg->type!=1))
{
// Text and multipart parts will not be shown as attachments
return(true);
}
else
{
// If there's no attachments, parts inside will be checked
if($estMsg->parts)
{
$partMsg=$estMsg->parts;
$i=0;
// Parts will be checked while no attachments found or not all of them checked
while(!(checkAttachments($partMsg[$i])) && ($i<sizeof($estMsg->parts)))
{
$i++;
}
// If any 'checkAttachment' calls returned 'true', 'i' should be
// equal to number of parts(after increased in while). So, no
// attachments found
if($i==sizeof($estMsg->parts))
{
return(false);
}
else
{
return(true);
}
}
else
{
// If no parts and text or multipart type, no attachments
return(false);
}
}
}
imap_close($con);
?>
Entweder habe ich jetzt den Code nicht verstanden oder da ist ein Fehler.