On 2025-01-04 19:07:57 +0000, Chris Green via Python-list wrote: > Stefan Ram <[email protected]> wrote: > > Chris Green <[email protected]> wrote or quoted: > > >From: =?utf-8?B?U8OpYmFzdGllbiBDcmlnbm9u?= <[email protected]> > > > 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: <[email protected]> (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.
|_|_) | |
| | | [email protected] | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"
signature.asc
Description: PGP signature
-- https://mail.python.org/mailman/listinfo/python-list
