Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #197140
| Path | csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Chris Green <cl@isbd.net> |
| Newsgroups | comp.lang.python |
| Subject | How to manage accented characters in mail header? |
| Date | Sat, 4 Jan 2025 14:31:24 +0000 |
| Lines | 37 |
| Message-ID | <satn4l-6sqh.ln1@q957.zbmc.eu> (permalink) |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 8bit |
| X-Trace | individual.net qyUGiZLdNRNMBDmbwLGlDw+mLBODl9OK4wL2+6hwzrRCQKh9M= |
| X-Orig-Path | not-for-mail |
| Cancel-Lock | sha1:5aoVMRgrgCtr3jRqNf+IRtUpDEI= sha256:osinuVfxx3kfdNi859H/IdJtL/C/0VAZkMJOqAKhhKk= |
| User-Agent | tin/2.6.2-20221225 ("Pittyvaich") (Linux/6.1.0-28-amd64 (x86_64)) |
| Xref | csiph.com comp.lang.python:197140 |
Show key headers only | View raw
I have a Python script that filters my incoming E-Mail. It has been
working OK (with various updates and improvements) for many years.
I now have a minor new problem when handling E-Mail with a From: that
has accented characters in it:-
From: Sébastien Crignon <sebastien.crignon@amvs.fr>
I use Python mailbox to parse the message:-
import mailbox
...
...
msg = mailbox.MaildirMessage(sys.stdin.buffer.read())
Then various mailbox methods to get headers etc.
I use the following to get the From: address:-
str(msg.get('from', "unknown").lower()
The result has the part with the accented character wrapped as follows:-
From: =?utf-8?B?U8OpYmFzdGllbiBDcmlnbm9u?= <sebastien.crignon@amvs.fr>
I know I have hit this issue before but I can't rememeber the fix. The
problem I have now is that searching the above doesn't work as
expected. Basically I just need to get rid of the ?utf-8? wrapped bit
altogether as I'm only interested in the 'real' address. How can I
easily remove the UTF8 section in a way that will work whether or not
it's there?
--
Chris Green
·
Back to comp.lang.python | Previous | Next — Next in thread | Find similar
How to manage accented characters in mail header? Chris Green <cl@isbd.net> - 2025-01-04 14:31 +0000
Re: How to manage accented characters in mail header? Peter Pearson <pkpearson@nowhere.invalid> - 2025-01-04 15:00 +0000
Re: How to manage accented characters in mail header? Chris Green <cl@isbd.net> - 2025-01-04 19:07 +0000
Re: How to manage accented characters in mail header? "Peter J. Holzer" <hjp-python@hjp.at> - 2025-01-06 20:43 +0100
csiph-web