PHP: Issues Capturing Attachments from Mailgun Webhooks

I’m processing emails via Mailgun webhooks in PHP. I capture sender and subject but cannot retrieve attachments. My new snippet logs attachment details below. What adjustment is needed?

<?php
$logFile = fopen(__DIR__ . '/data.log', 'w');
fwrite($logFile, print_r($_FILES, true));
fclose($logFile);
?>

hey, try reading php://input; sometimes mailgun sends attachments in raw multipart data not in $_FILES. i had similar probs and decoding the body manually did the trick, so check docs and your parser

In my experience, the issue often arises because Mailgun does not always deliver attachments as standard file uploads, and they may be embedded directly in the POST payload. I encountered a similar challenge where the attachments were actually found in specific POST parameters rather than in the $_FILES array. A solution for me was to check for an attachment count parameter and process each attachment from the POST data itself. This approach required modifying the parser to extract and decode the attachments correctly, ensuring that the webhook settings indeed forward them.