This module adds a custom Artisan command to clean up conversations in FreeScout based on various criteria.
- Clean up conversations based on mailbox IDs, statuses, age, and subject patterns.
- Perform a dry run to preview the conversations that would be deleted without actually deleting them.
- Confirm deletion of conversations before proceeding.
- Clean up old and large attachments to save storage space.
- Delete attachments based on age and size criteria.
- Detailed logging of cleaned attachments.
- Dry-run mode to preview deletions.
- Download the latest module zip file here. Do not use the master branch! The master branch is not stable and should only be used for development purposes.
- Transfer the zip file to the server in the Modules folder of FreeScout.
- Unpack the zip file.
- Remove the zip file.
- Activate the module via the Modules page in FreeScout.
To use the conversation cleanup command, run:
php artisan cleanup:conversations [options]Note
The cleanup command will not immediately delete conversations. It will prompt you to confirm the deletion of conversations before proceeding. If the --y option is provided, the command will not prompt for confirmation and will delete
conversations immediately.
Available options:
--mailbox-id: The IDs of the mailboxes to clean up conversations for (can be used multiple times).--status: The statuses of conversations to clean up (1=active, 2=pending, 3=closed, 4=spam, can be used multiple times).--older-than-days: Clean up conversations older than the specified number of days.--subject-starts-with: Clean up conversations with subjects starting with the specified string.--subject-contains: Clean up conversations with subjects containing the specified string.--subject-ends-with: Clean up conversations with subjects ending with the specified string.--limit: The maximum number of conversations to delete.--dry-run: Perform a dry run without actually deleting conversations.--y: Confirm deletion of conversations.
Examples:
- Clean up conversations older than 30 days:
php artisan cleanup:conversations --older-than-days=30 - Clean up closed conversations with subjects starting with "[RESOLVED]":
php artisan cleanup:conversations --status=3 --subject-starts-with="[RESOLVED]" - Perform a dry run to preview conversations that would be deleted:
php artisan cleanup:conversations --mailbox-id=1 --mailbox-id=2 --older-than-days=90 --dry-run - Remove all conversations that are older than 60 days and have the status spam or closed:
php artisan cleanup:conversations --older-than-days=60 --status=3 --status=4 - Remove all conversations that are older than 60 days and have the status spam or closed, but only if the subject starts with "SPAM":
php artisan cleanup:conversations --older-than-days=60 --status=3 --status=4 --subject-starts-with="SPAM" - Remove all conversations that are older than 60 days and have the status spam or closed and limit the amount of conversations to delete to 10:
php artisan cleanup:conversations --older-than-days=60 --status=3 --status=4 --limit=10
php artisan freescout:cleanup-attachments [options]Available options:
--dry-run: Preview what would be deleted without actually deleting.--min-age-days: Minimum age in days (default: 730 = 2 years).--min-size-kb: Minimum size in KB (default: 300).--max-size-mb: Maximum size in MB (optional).--mailbox: Specific mailbox ID to clean (optional).--limit: Maximum number of attachments to process in one run (default: 1000).
Examples:
- Preview deletions (dry run):
php artisan freescout:cleanup-attachments --dry-run - Delete attachments older than 1 year and larger than 500KB:
php artisan freescout:cleanup-attachments --min-age-days=365 --min-size-kb=500 - Clean only large files (1MB to 10MB) older than 6 months:
php artisan freescout:cleanup-attachments --min-age-days=180 --min-size-kb=1024 --max-size-mb=10 - Clean attachments from specific mailbox:
php artisan freescout:cleanup-attachments --mailbox=1 --min-age-days=730
Important
- Deleted attachments will return 404 errors when accessed.
- Links to cleaned attachments in emails or shared externally will break.
- Always test with
--dry-runfirst. - Consider backing up attachments before bulk deletion.
Feel free to add your own features by sending a pull request.
Interested in a custom FreeScout module or anything else? Please let us know via [email protected] or www.ljpc.solutions.
This module took us time to develop, but we decided to make it open source anyway. If we helped you or your business, please consider donating. Click here to donate.
