# העברת רשימת דיוור ל-Discourse (mbox, Listserv, Google Groups וכו')

**URL:** https://meta.discourse.org/t/migrate-a-mailing-list-to-discourse-mbox-listserv-google-groups-etc/79773
**Category:** Migrating to Discourse
**Tags:** how-to
**Created:** [4 בפברואר,‏ 2018,‏ 9:08pm UTC](https://meta.discourse.org/t/migrate-a-mailing-list-to-discourse-mbox-listserv-google-groups-etc/79773 "2018-02-04T21:08:05Z")
**Posts on this page:** 10
**Page:** 6

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [17 בדצמבר,‏ 2024,‏ 7:10am UTC](https://meta.discourse.org/t/migrate-a-mailing-list-to-discourse-mbox-listserv-google-groups-etc/79773/242 "2024-12-17T07:10:45Z")

</div>

The solution is literally in the [post](https://meta.discourse.org/t/migrate-a-mailing-list-to-discourse-mbox-listserv-google-groups-etc/79773/240) above yours. 😉

We should fix the script. Maybe you can create a PR that resolves the issue for everyone?

---

<div class="post-metadata">

### Author: ![Adam\_Skalicky](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/adam_skalicky/32/456821_2.png) [@Adam\_Skalicky](https://meta.discourse.org/u/Adam_Skalicky)
#### Post date: [17 בדצמבר,‏ 2024,‏ 5:45pm UTC](https://meta.discourse.org/t/migrate-a-mailing-list-to-discourse-mbox-listserv-google-groups-etc/79773/243 "2024-12-17T17:45:08Z")

</div>

> [@pfaffman](#):
>
> solve that. I think a `.du`

Thanks, that fixed it, sorry about that. In penance for my inability to read I opened [Added duplication to name to prevent modification of frozen string exception by adam-skalicky · Pull Request #30325 · discourse/discourse · GitHub](https://github.com/discourse/discourse/pull/30325) to save anyone else the shame of asking a dumb question.

---

<div class="post-metadata">

### Author: ![Jonathan5](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jonathan5/32/197134_2.png) [@Jonathan5](https://meta.discourse.org/u/Jonathan5)
#### Post date: [18 בינואר,‏ 2025,‏ 12:56am UTC](https://meta.discourse.org/t/migrate-a-mailing-list-to-discourse-mbox-listserv-google-groups-etc/79773/244 "2025-01-18T00:56:07Z")

</div>

Does this import script make Discourse replicate Mailman 2 email threading in any way (eg using the little Discourse arrow to signify "In-Reply-To) or is it purely chronological (for each thread based on Message-ID, In-Reply-To and References)?

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [18 בינואר,‏ 2025,‏ 6:36am UTC](https://meta.discourse.org/t/migrate-a-mailing-list-to-discourse-mbox-listserv-google-groups-etc/79773/245 "2025-01-18T06:36:23Z")

</div>

> [@Jonathan5](#):
>
> using the little Discourse arrow to signify "In-Reply-To

Yes, it does

---

<div class="post-metadata">

### Author: ![Jonathan5](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jonathan5/32/197134_2.png) [@Jonathan5](https://meta.discourse.org/u/Jonathan5)
#### Post date: [18 בינואר,‏ 2025,‏ 8:06am UTC](https://meta.discourse.org/t/migrate-a-mailing-list-to-discourse-mbox-listserv-google-groups-etc/79773/246 "2025-01-18T08:06:04Z")

</div>

Cool. Quite a few of my mailing list emails haven’t got the In-Reply-To and References headers that they should have, so might be imported as new topics rather than just replies. From memory, the script uses those headers or subject headers (not both).

I think I might have asked this in the distant past, but are there any non-manual ways of adding these headers to the MBOX file and/or otherwise rearranging the emails before or after importing to Discourse?

It’s possible now to merge topics and keep chronological order so maybe that’s the answer. They’d just be missing the little Discourse arrow to signify who the message was in reply to.

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [21 בינואר,‏ 2025,‏ 10:29pm UTC](https://meta.discourse.org/t/migrate-a-mailing-list-to-discourse-mbox-listserv-google-groups-etc/79773/247 "2025-01-21T22:29:32Z")

</div>

The mbox import script has two phases. The first one is indexing and outputs a SQLite database. You could either modify the data in the SQLite before the import, or you modify the Ruby script.

All the magic of sorting/grouping by subject or headers happens here:

> <https://github.com/discourse/discourse/blob/2a28cda15c4aef23850e780a63f60c47964839de/script/import_scripts/mbox/support/indexer.rb#L29-L35>

You could add your own logic of grouping if you know how you want to group emails.

---

<div class="post-metadata">

### Author: ![Jonathan5](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jonathan5/32/197134_2.png) [@Jonathan5](https://meta.discourse.org/u/Jonathan5)
#### Post date: [22 בינואר,‏ 2025,‏ 12:36am UTC](https://meta.discourse.org/t/migrate-a-mailing-list-to-discourse-mbox-listserv-google-groups-etc/79773/248 "2025-01-22T00:36:50Z")

</div>

It’ll be a while before I even consider something so complex!

At [https://bazaar.launchpad.net/~mailman-coders/mailman/2.1/view/head:/Mailman/Archiver/pipermail.py#L669](https://bazaar.launchpad.net/~mailman-coders/mailman/2.1/view/head:/Mailman/Archiver/pipermail.py#L669) Mailman 2’s Pipermail seems to look for the following in order of preference:

1. In-Reply-To.
2. References.
3. Oldest email with matching subject.

That combination of approaches seems ideal. In the third case, it might make sense for Discourse not to use the “in reply to” arrow.

From memory, Mailman 3’s Hyperkitty didn’t consider subject at all, which was not as good.

---

<div class="post-metadata">

### Author: ![Andro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/andro/32/173721_2.png) [@Andro](https://meta.discourse.org/u/Andro)
#### Post date: [2 בפברואר,‏ 2026,‏ 11:54am UTC](https://meta.discourse.org/t/migrate-a-mailing-list-to-discourse-mbox-listserv-google-groups-etc/79773/249 "2026-02-02T11:54:37Z")

</div>

Pardon me chiming in with a possibly stupid question, but I could not find a clear answer here. I would like to know if the import process creates a new Discourse user for each email, with de-duplication of course, or if they all go in as one system user. I have a mailing list with 20 years of posts and it’s pretty big and hard to experiment with. Abd also, what about replies in the original list? Do they get threaded in?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2 בפברואר,‏ 2026,‏ 12:53pm UTC](https://meta.discourse.org/t/migrate-a-mailing-list-to-discourse-mbox-listserv-google-groups-etc/79773/250 "2026-02-02T12:53:12Z")

</div>

Yes, the users get created, one per email address.

---

<div class="post-metadata">

### Author: ![bondero](https://avatars.discourse-cdn.com/v4/letter/b/b4bc9f/32.png) [@bondero](https://meta.discourse.org/u/bondero)
#### Post date: [3 באפריל,‏ 2026,‏ 2:28am UTC](https://meta.discourse.org/t/migrate-a-mailing-list-to-discourse-mbox-listserv-google-groups-etc/79773/252 "2026-04-03T02:28:34Z")

</div>

I was able to do a Google Takeout of my google groups, upload the .mbox files and import.

These steps were helpful to map the `data/folder` to an existing category, but this needs to be done in the `import` container, [not the `app` container like in this writeup](https://lifeafter40.net/converting-from-the-topicbox-group-email-system-to-the-discourse-open-source-discussion-platform/):

```plaintext
./launcher enter import
rails c

# Use the category ID shown in the URL, for example
# it's 16 when the category's path looks like this: /c/soccer/16
category = Category.find(16)

# Use the directory name where the mbox files are stored. For example,
# when the files are stored in import/data/foo, you should use "foo" as directory name.
category.custom_fields["import_id"] = "soccer"
category.save!

```

I already have users in Discourse that self-migrated, and so the import script failed to create contacts for them (probably not a bad thing), but the imported messages that these existing discourse users were involved with have the sender showing as `system` instead of their name.

Is there any way to make it map the existing users to their imported messages?

For now I undid everything by recovering from a recent backup. Ready to try again with some guidance on dealing with existing discourse users and their imported messages.

Update:

Claude helped solve the mapping of existing users, need to run this loop in the rails console, in addition to the above bit:

```plaintext
User.where("id > 0").find_each do |u|
  email = u.email.downcase
  unless u.custom_fields["import_id"].present?
    u.custom_fields["import_id"] = email
    u.save_custom_fields
  end
end

```

[Previous page](https://meta.discourse.org/t/migrate-a-mailing-list-to-discourse-mbox-listserv-google-groups-etc/79773.md?page=5)
