--- imp/lib/Compose.php	2020-09-22 08:03:11.356121591 +0200
+++ imp/lib/Compose.new	2025-02-19 12:25:35.151425111 +0100
@@ -3163,6 +3163,9 @@
         $stream = $part->getContents(array(
             'stream' => true
         ));
+        if (is_null($stream)) {
+            throw new IMP_Compose_Exception(sprintf(_("Could not attach %s to the message."), $part->getName()));
+        }
         rewind($stream);
         $dest_handle = fopen($atc_file, 'w+b');
         while (!feof($stream)) {