[GH-ISSUE #202] Feature request / query to migrate emails from MailHog to Mailpit #133

Closed
opened 2026-03-15 12:47:29 +03:00 by kerem · 2 comments
Owner

Originally created by @snaray4 on GitHub (Oct 31, 2023).
Original GitHub issue: https://github.com/axllent/mailpit/issues/202

Hi @axllent,

I am planning on migrating from MailHog to Mailpit and have some 100's of emails in one of the long lived QA environment that I would like to migrate to Mailpit. These are some the emails that we can't afford to lose. I checked the API docs, but couldn't find a way to create messages. Is there a way you would suggest I can achieve this? Thanks.

Originally created by @snaray4 on GitHub (Oct 31, 2023). Original GitHub issue: https://github.com/axllent/mailpit/issues/202 Hi @axllent, I am planning on migrating from MailHog to Mailpit and have some 100's of emails in one of the long lived QA environment that I would like to migrate to Mailpit. These are some the emails that we can't afford to lose. I checked the API docs, but couldn't find a way to create messages. Is there a way you would suggest I can achieve this? Thanks.
kerem closed this issue 2026-03-15 12:47:34 +03:00
Author
Owner

@axllent commented on GitHub (Oct 31, 2023):

Hi @snaray4. That's a good question. There is no a native way (and won't be) to read the MailHog database as that would involve me basically having to add all the MailHog database drivers, data structure and logic etc into Mailpit's codebase...

But they both share one common "injection" method - SMTP. The simplest solution I can think of is the following:

  1. Start Mailpit using the --use-message-dates flag - this will ensure that the message dates reflected in Mailpit's web UI/API reflect the dates embedded in the emails themselves, and not the current date/time they were received. This effectively "backdates" their supposed delivery dates/times as seen in the message overview.
  2. Assuming you can extract the original messages from MailHog as individual files (I believe its default was flat file storage which should be easy), you could then loop through them (script it in bash or something) and pass them through to Mailpit's sendmail (or a compatible sendmail client which allows you to set the host and port).

Something like this in the MailHog directory where your MailHog emails are kept) - untested:

for filename in *; do sendmail -S mailpit-server:1025 < "${filename}"; done

If you don't have a compatible sendmail client, then you could use Mailpit directly (also untested):

for filename in *; do mailpit sendmail -S mailpit-server:1025 < "${filename}"; done

Does this help you?

<!-- gh-comment-id:1786392416 --> @axllent commented on GitHub (Oct 31, 2023): Hi @snaray4. That's a good question. There is no a native way (and won't be) to read the MailHog database as that would involve me basically having to add all the MailHog database drivers, data structure and logic etc into Mailpit's codebase... But they both share one common "injection" method - SMTP. The simplest solution I can think of is the following: 1. Start Mailpit using the `--use-message-dates` flag - this will ensure that the message dates reflected in Mailpit's web UI/API reflect the dates embedded in the emails themselves, and not the current date/time they were received. This effectively "backdates" their supposed delivery dates/times as seen in the message overview. 2. Assuming you can extract the original messages from MailHog as individual files (I believe its default was flat file storage which should be easy), you could then loop through them (script it in bash or something) and pass them through to Mailpit's sendmail (or a compatible sendmail client which allows you to set the host and port). Something like this in the MailHog directory where your MailHog emails are kept) - **untested**: ```shell for filename in *; do sendmail -S mailpit-server:1025 < "${filename}"; done ``` If you don't have a compatible sendmail client, then you could use Mailpit directly (also untested): ```shell for filename in *; do mailpit sendmail -S mailpit-server:1025 < "${filename}"; done ``` Does this help you?
Author
Owner

@snaray4 commented on GitHub (Oct 31, 2023):

@axllent yes, this sounds like a plan. Thanks for the quick response, appreciate it.

<!-- gh-comment-id:1786402572 --> @snaray4 commented on GitHub (Oct 31, 2023): @axllent yes, this sounds like a plan. Thanks for the quick response, appreciate it.
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#133
No description provided.