Ragazzi, ho imparato a leggere la posta tramite le funzioni IMAP. Ho solo un problema, il download degli allegati.
Mi sono creato questa funzione per gli attachment
Codice PHP:
public function attach($id, $item, $filename)
{
$file=base64_decode(@imap_fetchbody($this->conn, $id, $item));
header('Pragma: private');
header('Cache-control: private, must-revalidate');
header("Content-Type: application/octet-stream");
header("Content-Length: " .(string)(filesize($file)) );
header('Content-Disposition: attachment; filename="'.($filename).'"');
readfile($file);
}
In effetti il download parte, ma si blocca subito. Dopo un po', il download dice di essere terminato ma in realtà scarica pochissimi bytes. Perchè?