mirror of
https://github.com/axllent/mailpit.git
synced 2026-04-26 00:35:51 +03:00
[GH-ISSUE #443] Add API call to dump all messages in text format .. WAS Bring back MailDir storage. #288
Labels
No labels
awaiting feedback
bug
docker
documentation
enhancement
github_actions
invalid
pull-request
question
stale
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/mailpit#288
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @skyscooby on GitHub (Feb 14, 2025).
Original GitHub issue: https://github.com/axllent/mailpit/issues/443
Can you re-enable the MailDir repository feature so that messages get dumped on the filesystem like was possible with MailHog? It wouldn't have to replace the DB setup... the source of truth could continue being the DB, just automatically write out the messages to a filesystem optionally.. tthe Maildir format is a standard that goes way back.. it's something easy to tar up and upload as an artifact in CI or pass around. Having the raw messages in text format where
sed,awkandgrepcan be used against them was really convenient in MailHog for basic test cases.. it seems like this would be pretty easy and is really the only thing that makes mailpit is worse than Mailhog was.@axllent commented on GitHub (Feb 14, 2025):
Let me start off by pointing out that MailHog's "maildir" storage is not maildir at all, it just writes the emails directly to a specified folder similar to maildir, except the maildir format includes a structured format which MailHog does not.
Also, Mailpit is not a fork of MailHog, it's a completely separate application that shares similar functionality, so there is nothing to "bring back" as it never had maildir storage ;-)
Finally, I will also state that Mailpit will never use maildir to store & read messages, vs: the database. I know you already said this, I am just stating it for anyone else who may read this. MailHog's "maildir" storage is ridiculously inefficient and CPU intensive. It's not all related to maildir storage of course, much of it is due to the inefficiencies of how MailHog processes messages, but it's a good indicator of the general performance differences between the two.
Mailpit's SQLite database also allows it to have a fast, flexible and structured mess listing & search which maildir format does not provide. To provide a quick benchmark on my laptop:
So to get back to your request... I am trying to understand the real use-case here. The intended approach to integration testing is to use the API, which could be as simple as
curl -o message.txt htp://<mailpit-host>/api/v1/message/latest/rawwhich would download the latest message (raw source) which could then be processed withsed,awkorgrepetc, and isn't limited to the same host as Mailpit either. I don't understand how having multiple messages saved to a directory would be helpful for testing when you don't know which one is which, as they would get saved with random IDs.Exporting all messages from the database I can understand the use-case for though, so there is currently no need to elaborate on this. I think a manual way of exporting all messages in plain text format (similar to "maildir") is a good idea.
So, for now, could you please explain any downside to using the API to retrieve the latest message in your basic testing?
@skyscooby commented on GitHub (Feb 14, 2025):
It really is awesome! That's a heck of a performance boost, congrats.. Sorry I thought since you have that silly Chaos Jim monkey thing in this service too that it was a continuation... vs a scratch thing.. thanks for the correction.
If there was an API call to dump all the messages to text that would completely address my need as an easy way to preserve them all after a CI run. (even it seems like a tool to do this through the API might be possible but I assume slower than a single API call to do it) .. and yes we will use the API for any new test cases... Thx u.
@axllent commented on GitHub (Feb 14, 2025):
Many features from MailHog are "replicated" due to user demand as they are required for various levels of integration testing, however Mailpit is ultimately a "from scratch" thing. Mailpit does however bring a range of additional features, completely different UI, and of course major performance improvements (which was originally the whole reason I started it).
The API doesn't currently have a "dump all" feature, however I will look into a method of utilising either the API or the database file directly (as a choice) to dump all messages to a directory. I see this as a useful general addition for archiving/export purposes.
Leave this with me 👍
@axllent commented on GitHub (Feb 15, 2025):
I've added this new feature to v1.22.3 and added documentation to the website. This should allow you to easily export all messages from the DB to a folder.
Please confirm this works as expected? Thanks.
@skyscooby commented on GitHub (Feb 15, 2025):
Fantastic!!! Thank you.. this is perfect.