php-imap icon indicating copy to clipboard operation
php-imap copied to clipboard

How to avoid multiple/duplicate attachments dowload?

Open oioix opened this issue 3 years ago • 0 comments

PHP IMAP version: 5.0.1 PHP Version: 8.1 Type of execution: CLI or Web Server

I want to dowload the attachments but not multiple times.

Current situation: The attachments file informations like filename, path, mime type, etc. is requestable with $mail->getAttachments() but -as I learned- only if $mailbox->ignoreAttachments() (or equivalent in the connection settings) is NOT set to false. The problem with this is, that if $mailbox->ignoreAttachments() is set to true all the attachment files are transferred from new at every single connection, even if I already stored them, which slows down performance. It looks like the ignoreAttachments option can not be used for the single emails whithin a request.

My questions: Is there a way to retrieve the attachment file information with $mail->getAttachments() BUT without the mandatory need to transfer the entire file? I know that I can use/not use fileToDisk() to control if the attachment gets saved on disk or not. But I would like to init the file-transfer between the Servers only, if the file is really needed for storage.

In short I would like to ...

  1. ... get E-Mail including detail-informations about exisiting attachments (no file transfer of attachments yet)
  2. ... only if detail-information leads to decision to dowload the attachments -> init file transfer and store the attachments

(edited since I could solve a part of my prior question already)

oioix avatar Dec 26 '22 21:12 oioix