Re: How to manage accented characters in mail header?

Liste des GroupesRevenir à cl python 
Sujet : Re: How to manage accented characters in mail header?
De : hjp-python (at) *nospam* hjp.at (Peter J. Holzer)
Groupes : comp.lang.python
Date : 06. Jan 2025, 20:43:21
Autres entêtes
Message-ID : <mailman.52.1736192610.2912.python-list@python.org>
References : 1 2 3 4
Pièces jointes : signature.asc (application/pgp-signature)
On 2025-01-04 19:07:57 +0000, Chris Green via Python-list wrote:
Stefan Ram <ram@zedat.fu-berlin.de> wrote:
Chris Green <cl@isbd.net> wrote or quoted:
From: =?utf-8?B?U8OpYmFzdGllbiBDcmlnbm9u?= <sebastien.crignon@amvs.fr>
 
Is there a simple[r] way to extract just the 'real' address between
the <>, that's all I actually need.  I think it has the be the last
chunk of the From: doesn't it?

No,
    From: <sebastien.crignon@amvs.fr> (Sébastien Crignon)
would also be permissible (properly encoded, of course), and even
    From: < sebastien (Sébastien) . crignon (Crignon) @ amvs . fr >
(although I think the latter is deprecated).

And also, there can be more than one address in a From header.

To properly extract email addresses from a header, use
email.utils.getaddresses(). You don't have to decode the header first.
The MIME-encoding is supposed to not interfere with parsing headers for
machine-readable information like addresses or message ids.

        hp

--
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp@hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"


Date Sujet#  Auteur
4 Jan 25 * How to manage accented characters in mail header?6Chris Green
4 Jan 25 +* Re: How to manage accented characters in mail header?4Stefan Ram
4 Jan 25 i`* Re: How to manage accented characters in mail header?3Chris Green
4 Jan 25 i +- Re: How to manage accented characters in mail header?1Stefan Ram
6 Jan 25 i `- Re: How to manage accented characters in mail header?1Peter J. Holzer
4 Jan 25 `- Re: How to manage accented characters in mail header?1Peter Pearson

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal