# Auto delete emails after X days

**URL:** <https://forum.hestiacp.com/t/auto-delete-emails-after-x-days/5258>\
**Category:** Mail\
**Created:** [December 31, 2021, 1:00am UTC](https://forum.hestiacp.com/t/auto-delete-emails-after-x-days/5258 "2021-12-31T01:00:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wicked](https://forum.hestiacp.com/letter_avatar_proxy/v4/letter/w/f04885/32.png) [@Wicked](https://forum.hestiacp.com/u/Wicked)\
**Post date:** [December 31, 2021, 1:00am UTC](https://forum.hestiacp.com/t/auto-delete-emails-after-x-days/5258/1 "2021-12-31T01:00:30Z")

</div>

Hello,

I need to delete emails that are over XX days old automatic. Is there a cron I can setup for this or any other way? I’ve been searching for a while but haven’t found any easy ways to do it.

Thanks.

---

<div class="post-metadata">

**Author:** ![Raphael](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/raphael/32/5217_2.png) [@Raphael](https://forum.hestiacp.com/u/Raphael)\
**Post date:** [December 31, 2021, 1:38am UTC](https://forum.hestiacp.com/t/auto-delete-emails-after-x-days/5258/2 "2021-12-31T01:38:00Z")

</div>

Should work similar to this here, ofc adjust the folder name: [Cron to purge Trash/Spam folder](https://forum.hestiacp.com/t/cron-to-purge-trash-spam-folder/2275)

---

<div class="post-metadata">

**Author:** ![Wicked](https://forum.hestiacp.com/letter_avatar_proxy/v4/letter/w/f04885/32.png) [@Wicked](https://forum.hestiacp.com/u/Wicked)\
**Post date:** [January 1, 2022, 3:08pm UTC](https://forum.hestiacp.com/t/auto-delete-emails-after-x-days/5258/3 "2022-01-01T15:08:56Z")

</div>

Found a very easy way using doveadm expunge. Not really a good solution as you can´t run it for all users. But I only have one mailbox.

```auto
doveadm expunge -u mail@domain.com mailbox Inbox savedbefore 5d

```

---

<div class="post-metadata">

**Author:** ![system](https://forum.hestiacp.com/uploads/default/original/1X/d9a5b68bf50ced83e880b56452e592b204761b19.png) [@system](https://forum.hestiacp.com/u/system)\
**Post date:** [January 31, 2022, 3:09pm UTC](https://forum.hestiacp.com/t/auto-delete-emails-after-x-days/5258/4 "2022-01-31T15:09:28Z")

</div>

Closed on January 31, 2022, 3:09pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
