# Working on a mailman2 to discourse migration script

**URL:** https://meta.discourse.org/t/working-on-a-mailman2-to-discourse-migration-script/169220
**Category:** Support
**Created:** [November 4, 2020, 1:43pm UTC](https://meta.discourse.org/t/working-on-a-mailman2-to-discourse-migration-script/169220 "2020-11-04T13:43:41Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![dachary](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dachary/32/119731_2.png) [@dachary](https://meta.discourse.org/u/dachary)
#### Post date: [November 4, 2020, 1:43pm UTC](https://meta.discourse.org/t/working-on-a-mailman2-to-discourse-migration-script/169220/1 "2020-11-04T13:43:41Z")

</div>

Bonjour,

Today I start working on a python script to migrate a mailman2 mailing list (archives and config.pck) using the discourse API only. If anyone is interested, it is happening [here](https://lab.enough.community/discourse/mailman2discourse) and I’ll update this topic with progress.

Any comment on whatever people need or comments about how to better do that are very welcome, of course 🙂

Cheers

---

<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: [November 4, 2020, 2:42pm UTC](https://meta.discourse.org/t/working-on-a-mailman2-to-discourse-migration-script/169220/2 "2020-11-04T14:42:29Z")

</div>

> **digest\_members** : discarded. It is not possible to request a digest mode on a per-category basis.

Maybe “Watching first post” would be a rough equivalent, depending how often there are new threads/topics and how often in practice a digest was sent on the list.

---

<div class="post-metadata">

### Author: ![dachary](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dachary/32/119731_2.png) [@dachary](https://meta.discourse.org/u/dachary)
#### Post date: [November 29, 2020, 8:20pm UTC](https://meta.discourse.org/t/working-on-a-mailman2-to-discourse-migration-script/169220/3 "2020-11-29T20:20:49Z")

</div>

A first version of the script was published at [Client Challenge](https://pypi.org/project/mailman2discourse/). It works for me, hopefully it will also help others. If not let me know and I’ll try to adapt the script.

---

<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: [May 14, 2021, 10:29am UTC](https://meta.discourse.org/t/working-on-a-mailman2-to-discourse-migration-script/169220/4 "2021-05-14T10:29:07Z")

</div>

How does it deal with lists where [from\_is\_list](https://wiki.list.org/DOC/Mailman%202.1%20List%20Administrators%20Manual) is set to Munge From or Wrap Message (or the equivalent DMARC-only settings are used)? Is it able to work out which user sent those messages?

---

<div class="post-metadata">

### Author: ![dachary](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dachary/32/119731_2.png) [@dachary](https://meta.discourse.org/u/dachary)
#### Post date: [May 14, 2021, 10:49am UTC](https://meta.discourse.org/t/working-on-a-mailman2-to-discourse-migration-script/169220/5 "2021-05-14T10:49:50Z")

</div>

It does not, I’ll take a look at what it would require.

---

<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: [May 14, 2021, 10:53am UTC](https://meta.discourse.org/t/working-on-a-mailman2-to-discourse-migration-script/169220/6 "2021-05-14T10:53:37Z")

</div>

Thanks. If it helps, the original sender’s email address appears often (always?) appears in the “Cc:” header of the email, at least when from\_is\_list is Munge From.

---

<div class="post-metadata">

### Author: ![dachary](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dachary/32/119731_2.png) [@dachary](https://meta.discourse.org/u/dachary)
#### Post date: [May 14, 2021, 10:54am UTC](https://meta.discourse.org/t/working-on-a-mailman2-to-discourse-migration-script/169220/7 "2021-05-14T10:54:21Z")

</div>

[from\_is\_list](https://wiki.list.org/DOC/Mailman%202.1%20List%20Administrators%20Manual)

> **from\_is\_list**
> 
> - This applies to all non-digest messages sent by the list. For settings that apply only to messages whose From: domain publishes a DMARC p=reject or p=quarantine policy, see the dmarc\_moderation\_action description in the [Sender filters](https://wiki.list.org/DOC/Mailman%202.1%20List%20Administrators%20Manual#Sender_filters) section.
> 
> If set to Munge From, it replaces the From: header address with the list’s posting address to mitigate issues stemming from the original From: domain’s DMARC or similar policies and puts the original From: address in a Reply-To: header.
> 
> If set to Wrap Message it wraps the original message as a MIME subpart of an outer message with From: and Reply-To: headers as above.

I don’t think Discourse provides a similar feature. I’ve not seen any site settings that would be a match. And I browsed all email related settings a few times in the past few days, in the context of an ongoing mailman2 migration.

---

<div class="post-metadata">

### Author: ![dachary](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dachary/32/119731_2.png) [@dachary](https://meta.discourse.org/u/dachary)
#### Post date: [May 14, 2021, 10:55am UTC](https://meta.discourse.org/t/working-on-a-mailman2-to-discourse-migration-script/169220/8 "2021-05-14T10:55:44Z")

</div>

Maybe your question is related to how mails are imported from the archives rather than implementing the feature in Discourse?

---

<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: [May 14, 2021, 11:01am UTC](https://meta.discourse.org/t/working-on-a-mailman2-to-discourse-migration-script/169220/9 "2021-05-14T11:01:22Z")

</div>

Discourse operates essentially in the same way as Mailman 2 with from\_is\_list = Munge From – with those settings every Mailman list email is “From: [listname@example.com](mailto:listname@example.com)” (rather than “From: [joebloggs@email.com](mailto:joebloggs@email.com)”) – and similarly every email notification from Discourse is from the same forum email address ([noreply@forum.example.com](mailto:noreply@forum.example.com) or whatever).

But I wasn’t really asking about replicating the feature in Discourse. [Edit - as you have realised - I’ve just seen your second reply!]

I was meaning: when this Mailman setting is on, would your script import these messages as being from a single Discourse user (whose email address is [listname@example.com](mailto:listname@example.com)), or would it instead be able to identify the original sender?

Hope that makes sense!

---

<div class="post-metadata">

### Author: ![dachary](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dachary/32/119731_2.png) [@dachary](https://meta.discourse.org/u/dachary)
#### Post date: [May 14, 2021, 11:11am UTC](https://meta.discourse.org/t/working-on-a-mailman2-to-discourse-migration-script/169220/10 "2021-05-14T11:11:18Z")

</div>

Thanks for explaining. The mailman2discourse script does not play a role in this because it does not import the messages. The import of the messages is done via the Discourse [mbox importer](https://meta.discourse.org/t/importing-mailing-lists-mbox-listserv-google-groups-emails/79773).

I think it would set the author of all mails to [listname@example.com](mailto:listname@example.com). I do not see anything in [discourse/script/import\_scripts/mbox/importer.rb](https://github.com/discourse/discourse/blob/master/script/import_scripts/mbox/importer.rb) that would suggest otherwise. It would be a feature to add and maybe control via a **use\_reply\_to\_instead\_of\_from** field in the settings.yml file?

---

<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: [May 14, 2021, 11:18am UTC](https://meta.discourse.org/t/working-on-a-mailman2-to-discourse-migration-script/169220/11 "2021-05-14T11:18:20Z")

</div>

I see now, thanks.

Unfortunately I’ve also got _reply\_goes\_to\_list_ set to “This list” (which changes the “Reply-To:” header) so we’d have to think of another solution. Or maybe not… I’ll post a question to the other topic. Thanks for your help.

---

<div class="post-metadata">

### Author: ![dachary](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dachary/32/119731_2.png) [@dachary](https://meta.discourse.org/u/dachary)
#### Post date: [June 12, 2021, 10:50pm UTC](https://meta.discourse.org/t/working-on-a-mailman2-to-discourse-migration-script/169220/12 "2021-06-12T22:50:39Z")

</div>

For the record, the migration script reached a stage where it is usable and a HOWTO is available:

> [@HOWTO migrate from mailman2 to discourse](https://meta.discourse.org/t/howto-migrate-from-mailman2-to-discourse/193608/2):
>
> I started [working on this script last year](https://meta.discourse.org/t/working-on-a-mailman2-to-discourse-migration-script/169220) and had the opportunity to put it to the test in May 2021 when migrating [the Spip mailing lists](https://blog.spip.net/Les-listes-de-diffusion-evoluent-Mailman-Discourse.html). The script is still very young but I’m now confident that it is usable. There still are many manual steps involved in the import and I would love to have something like discourse import --mailman2 config.pck mbox-archives-directory that would “just work”. However I don’t plan to implement this. I’m happy with [custom shell scripts](https://lab.enough.community/dachary/rezo-import/-/blob/master/rezo-import) and I don’t see how they co…

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [July 12, 2021, 10:51pm UTC](https://meta.discourse.org/t/working-on-a-mailman2-to-discourse-migration-script/169220/13 "2021-07-12T22:51:40Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
