[GH-ISSUE #218] Monitor drive space #146

Closed
opened 2026-03-15 12:51:02 +03:00 by kerem · 1 comment
Owner

Originally created by @sdrakey on GitHub (Dec 26, 2023).
Original GitHub issue: https://github.com/axllent/mailpit/issues/218

Would just like to say great work on this.

I have mailpit running on it's own drive, so as not to use all the space if someone decides to test sending thousands of mails.

I see that there is an option to limit the number of messages in the database, but would it be possible have mailpit monitor a drive and remove the oldest messages to keep the free space below a certain size or percentage.

I used inbucket before moving to mailpit and it had a status page which showed the amount of messages in mail store, message per minute etc, would that be possible on sidebar ?

Is there any instructions for compiling mailpit on/for windows ?

Thanks
Simon

Originally created by @sdrakey on GitHub (Dec 26, 2023). Original GitHub issue: https://github.com/axllent/mailpit/issues/218 Would just like to say great work on this. I have mailpit running on it's own drive, so as not to use all the space if someone decides to test sending thousands of mails. I see that there is an option to limit the number of messages in the database, but would it be possible have mailpit monitor a drive and remove the oldest messages to keep the free space below a certain size or percentage. I used inbucket before moving to mailpit and it had a status page which showed the amount of messages in mail store, message per minute etc, would that be possible on sidebar ? Is there any instructions for compiling mailpit on/for windows ? Thanks Simon
kerem closed this issue 2026-03-15 12:51:07 +03:00
Author
Owner

@axllent commented on GitHub (Dec 26, 2023):

Would just like to say great work on this.

Thanks for using Mailpit!

I have mailpit running on it's own drive, so as not to use all the space if someone decides to test sending thousands of mails.

I see that there is an option to limit the number of messages in the database, but would it be possible have mailpit monitor a drive and remove the oldest messages to keep the free space below a certain size or percentage.

This is an interesting approach. however I do not think it would work, at least not reliably, as different filesystems and operating systems report used size differently. But let's explore this approach a little further:

Let's say I set a 10MB limit - I receive 100 small messages, well below the 10MB limit, and then an hour later I get an 11MB message - all messages then get automatically deleted because the latest one pushed it over the limit?

There are further technical complications/limitations to this approach too - messages are stored using zstd compression in Mailpit's SQLite database, meaning there is no way to actually pre-determine the actual size of any message's disk storage. A 10MB message may only take up 1MB of actual storage space, but it could also take up 10MB depending on the content of that message (eg: an image attachment vs: a large plain text message).

Then there is also the fact that these messages are all stored within SQLite, and SQLite does not automatically reduce in size when messages are deleted. In order to reduce the size of SQLite an expensive CPU & disk operation is required to VACUUM the database. Depending on the size of the database, this process can take anywhere between a few milliseconds to several minutes. During this time for large databases, the database becomes very slow.

This means that the only way this proposal could work would be to delete individual messages, and after each delete a database VACUUM. This would lead to all kinds of very serious performance issues. At the moment Mailpit does automatically VACUUM the database after any message deletes, but only after 5 minutes of inactivity as to minimise performance issues.

I think you can see how this proposal would not work.

I used inbucket before moving to mailpit and it had a status page which showed the amount of messages in mail store, message per minute etc, would that be possible on sidebar ?

Mailpit has some statistics when you click the "About" link at the bottom, but I will investigate adding some other data to that. This cannot be refreshed very often though as each time those statistics are "refreshed" Mailpit does a check to see if it is the latest version - meaning Github would get a lot of connections if this was refreshed every second or so.

Is there any instructions for compiling mailpit on/for windows ?

Not on Windows specifically (and I do not use Windows), but there are instructions in the docs which should apply to all platforms.

<!-- gh-comment-id:1869753632 --> @axllent commented on GitHub (Dec 26, 2023): > Would just like to say great work on this. Thanks for using Mailpit! > I have mailpit running on it's own drive, so as not to use all the space if someone decides to test sending thousands of mails. > > I see that there is an option to limit the number of messages in the database, but would it be possible have mailpit monitor a drive and remove the oldest messages to keep the free space below a certain size or percentage. This is an interesting approach. however I do not think it would work, at least not reliably, as different filesystems and operating systems report used size differently. But let's explore this approach a little further: Let's say I set a 10MB limit - I receive 100 small messages, well below the 10MB limit, and then an hour later I get an 11MB message - all messages then get automatically deleted because the latest one pushed it over the limit? There are further technical complications/limitations to this approach too - messages are stored using zstd compression in Mailpit's SQLite database, meaning there is no way to actually pre-determine the actual size of any message's disk storage. A 10MB message may only take up 1MB of actual storage space, but it could also take up 10MB depending on the content of that message (eg: an image attachment vs: a large plain text message). Then there is also the fact that these messages are all stored within SQLite, and SQLite does not automatically reduce in size when messages are deleted. In order to reduce the size of SQLite an expensive CPU & disk operation is required to `VACUUM` the database. Depending on the size of the database, this process can take anywhere between a few milliseconds to several minutes. During this time for large databases, the database becomes very slow. This means that the only way this proposal could work would be to delete individual messages, and after each delete a database `VACUUM`. This would lead to all kinds of very serious performance issues. At the moment Mailpit does automatically `VACUUM` the database after any message deletes, but only after 5 minutes of inactivity as to minimise performance issues. I think you can see how this proposal would not work. > I used inbucket before moving to mailpit and it had a status page which showed the amount of messages in mail store, message per minute etc, would that be possible on sidebar ? Mailpit has some statistics when you click the "About" link at the bottom, but I will investigate adding some other data to that. This cannot be refreshed very often though as each time those statistics are "refreshed" Mailpit does a check to see if it is the latest version - meaning Github would get a lot of connections if this was refreshed every second or so. > Is there any instructions for compiling mailpit on/for windows ? Not on Windows specifically (and I do not use Windows), but there are [instructions in the docs](https://mailpit.axllent.org/docs/install/source/) which should apply to all platforms.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/mailpit#146
No description provided.