Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Search API HTML Element Filter 1.0.7 Minor update available for module search_api_html_element_filter (1.0.7). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). UI Patterns (SDC in Drupal UI) 2.0.18 Minor update available for module ui_patterns (2.0.18). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

This module automatically deletes uploaded Webform attachment files from your private file storage after the last email handler has processed a submission. It helps keep your private file system clean by removing temporary files specific to each Webform submission.

⚠️ Warning !!! This module will delete files under your private file system so do use with caution and backup your website before testing

Cleans up uploaded webform attachment files from the private file directory after the last email handler sends. This avoids leaving temporary files in private://webform/<webform-id>/ after emails are delivered.

Requirements

  • Drupal 10 or 11
  • Webform
  • Private file system configured (for cleanup to run)

Configuration

  1. Go to Structure → Webforms → Webform email cleanup (path: /admin/config/content/webform-email-cleanup).
  2. Check the webforms for which attachment files should be deleted after the last email handler sends.
  3. Save configuration.

Only the last email handler (by weight) that is triggered for the current submission (i.e. not disabled and conditions pass) runs the cleanup. If you use conditional logic on handlers, only handlers that actually run for that submission are considered.

How it works

  • The module replaces the core Webform email handler with an extended version (same plugin ID email).
  • After sendMessage() runs successfully, if the current handler is the last triggered email handler for the webform and the webform is in the cleanup list, it deletes the contents of private://webform/&lt;webform-machine-name&gt;/.
  • Files and subdirectories in that path are removed. The directory itself may remain. Cleanup is logged and errors are reported via the logger and (when applicable) the messenger.

Notes

  • Private files: Cleanup only runs when the private file system is configured. If it is not, a warning is logged and no files are deleted.
  • Plugin override: Enabling this module replaces the default Webform email handler. Clear cache after enabling so the override is applied.
  • Managed files: This module removes files from the filesystem under the webform's private directory. It does not delete managed file entities from the database; ensure your workflow does not rely on those files remaining on disk after the last email is sent.

Activity

Total releases
3
First release
Feb 2026
Latest release
4 months ago
Releases (12 mo)
3 ▲ from 0
Maintenance
Active

Release Timeline

Releases

Version Type Release date
1.0.1 Stable Mar 5, 2026
1.0.0 Stable Feb 10, 2026
1.0.x-dev Dev Feb 10, 2026