# Migliorare il parsing delle email di Mailman

**URL:** <https://meta.discourse.org/t/improving-mailman-email-parsing/253041>\
**Category:** Feature\
**Tags:** completed\
**Created:** [26 Gennaio 2023, 10:50pm UTC](https://meta.discourse.org/t/improving-mailman-email-parsing/253041 "2023-01-26T22:50:14Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)\
**Post date:** [17 Maggio 2023, 11:29pm UTC](https://meta.discourse.org/t/improving-mailman-email-parsing/253041/6 "2023-05-17T23:29:07Z")

</div>

> <https://github.com/discourse/discourse/pull/21627>
>
> https://meta.discourse.org/t/improving-mailman-email-parsing/253041
> 
> When mirr…oring a public mailling list which uses mailman, there were some cases where the incoming email was not associated to the proper user.
> 
> As it happens, for various (undertermined) reasons, the email from the sender is often not in the \`From\` header but can be in any of the following headers: \`Reply-To\`, \`CC\`, \`X-Original-From\`, \`X-MailFrom\`.
> 
> It might be in other headers as well, but those were the ones we found the most reliable.
> 
> There's also a new \`emails:fix\_mailman\_users\` rake task to fix wrongfully associated users.

Il succo è che ho ideato un algoritmo che funziona per tutte le versioni (che ho visto in circolazione).

1. Ottieni l’indirizzo email della mailing list dall’header `List-Post` o `X-BeenThere`.
2. L’email del mittente sarà in uno dei seguenti header: `From`, `Reply-To`, `X-MailFrom` o `X-Original-From`. Quindi scorri questi e restituisci il primo che non corrisponde all’indirizzo email della mailing list.

---

_[View the full topic](https://meta.discourse.org/t/improving-mailman-email-parsing/253041)._
