Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API call to dump all messages in text format .. WAS Bring back MailDir storage. #443

Open
skyscooby opened this issue Feb 14, 2025 · 3 comments
Labels
enhancement New feature or request

Comments

@skyscooby
Copy link

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, awk and grep can 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
Copy link
Owner

axllent commented 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:

  • To store 816 messages it takes MailHog 67s, in Mailpit 9s (7+ times faster)
  • To load an overview of 816 messages in MailHog it takes 47s, in Mailpit 0.15s (300+ times faster)
  • To search 816 messages for a single word "test" in MailHog it takes 19.7s, in Mailpit 0.1s (197 times faster)

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/raw which would download the latest message (raw source) which could then be processed with sed, awk or grep etc, 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
Copy link
Author

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.

@skyscooby skyscooby changed the title Bring back MailDir storage. Add API call to dump all messages in text format .. WAS Bring back MailDir storage. Feb 14, 2025
@axllent
Copy link
Owner

axllent commented Feb 14, 2025

Many features from MailHog are "replicated" due to user demand as they are required for various 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 axllent added the enhancement New feature or request label Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants