Where does MailHog keep its files?

While using DesktopServer, I discovered that its local mail catching implementation stored messages as separate .eml files a few directories deep from XAMPP/. The nice thing about this is that on a Mac, QuickLook works on these files. So instead of using its localhost web UI, I could just keep that window open in the Finder and flip through messages really fast.

Assuming messages are stored similarly with MailHog/Local, I’d like to do the same thing by mapping the VM directory to one on my Mac via the Volumes Manager add-on. Couldn’t find where it’s specified by poking around the filesystem, so does anyone here know?


Hi Yoni,

Right now Local + MailHog is configured to store the e-mails in-memory. See https://github.com/mailhog/MailHog/blob/master/docs/CONFIG.md, specifically the MH_STORAGE flag.

If you’re using the “Custom” environment, you can easily customize the flags that are used when starting Local. You’ll want to edit the /etc/scripts/startup.sh file.

You can get there by right-clicking on the site, then going to “Open Site SSH”. Then, you can edit it by entering nano /etc/scripts/startup.sh.

Note: Making a mistake with in this file can cause your site to not start. Be careful!

Ok, thanks! The MailHog docs seem a little minimalist. So when you pointed out that Local keeps the MailHog default of in-memory storage, I worried that it’d just lose messages upon restart. A quick test reveals that’s true. I guess there are probably lots of developers who prefer frequent email purges on local installs, but I would have expected a few day’s persistence even across restarts.

So to test out whether I could map the directory to my Mac, I just found the line that starts Mailhog in /etc/scripts/startup.sh and appended -storage maildir to it. I found that it creates a directory within /tmp. Since the storage directory gets a new name across each machine reboot, I just mapped the whole /tmp directory to my Mac so I could see any subdirectory. The old storage directory doesn’t get deleted on reboot, though presumably it’ll disappear eventually. Messages are now stored in individual files, ending in .example. If you change their filename extension to .eml, the MailHog web interface reads them just fine. However, for HTML emails, QuickLook just displays the source instead of actually rendering them. Mails created by DesktopServer do render correctly in QL.

I realize that none of this is really Local’s issue, unless maybe you want to expose MailHog’s storage option within the app. Just figured I’d document what I found in case anyone else is interested!

1 Like