Ich versuche, eine kleine Webmail-App zu bauen. Wenn ich alle E-Mails im Posteingang lese, möchte ich für jede E-Mail anzeigen, ob Anhänge vorhanden sind. Das funktioniert, aber das Problem ist, dass es zu lange dauert, etwa 0,5 Sekunden für 1Mb E-Mail-Attach. Multiplizieren Sie das mit allen E-Mails im Posteingang, die große Attach-Dateien haben: | Meine Frage ist: Wie überprüft man, ob eine E-Mail angehängt ist, ohne die gesamte E-Mail zu laden? Ist das möglich ? Bellow ist der Code ich jetzt benutze:php imap überprüfen, ob E-Mail Anhang hat
function existAttachment($part)
{
if (isset($part->parts))
{
foreach ($part->parts as $partOfPart)
{
$this->existAttachment($partOfPart);
}
}
else
{
if (isset($part->disposition))
{
if ($part->disposition == 'attachment')
{
echo '<p>' . $part->dparameters[0]->value . '</p>';
// here you can create a link to the file whose name is $part->dparameters[0]->value to download it
return true;
}
}
}
return false;
}
function hasAttachments($msgno)
{
$struct = imap_fetchstructure($this->_connection,$msgno,FT_UID);
$existAttachments = $this->existAttachment($struct);
return $existAttachments;
}
Das downloadet die ganze E-Mail, was ich vermeiden wollte –