Drupal is a registered trademark of Dries Buytaert

⚠️ 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
2
First release
Feb 2026
Latest release
3 weeks ago
Release cadence
0 days
Stability
50% stable

Releases

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