Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Life is a whim of several billion cells to be you for a while.


devel / comp.lang.python / Re: [SOLVED]Just getting my From header field back?

SubjectAuthor
* Just getting my From header field back?Stefan Ram
`* Re: [SOLVED]Just getting my From header field back?Stefan Ram
 `- Re: [SOLVED]Just getting my From header field back?jak

1
Just getting my From header field back?

<header-20231130172133@ram.dialup.fu-berlin.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24582&group=comp.lang.python#24582

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram...@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Just getting my From header field back?
Date: 30 Nov 2023 16:21:54 GMT
Organization: Stefan Ram
Lines: 34
Expires: 1 Dec 2024 11:59:58 GMT
Message-ID: <header-20231130172133@ram.dialup.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de c8GqvzofQGkatyTNbM22lgGRIZ/3O/mRUDEFKMwwUVllKT
Cancel-Lock: sha1:bQ+aTctAF5VPY4zHwAdqvPb7FzQ= sha256:dUdn7O4EQ3L3ecrBX+s8usO4dEvgpHRaJznjgAZnTh8=
X-Copyright: (C) Copyright 2023 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE-1901, en-US, it, fr-FR
 by: Stefan Ram - Thu, 30 Nov 2023 16:21 UTC

I create an e-mail message, and I just want to get the From
header field back as I supplied it (as the documentation says:
"__getitem__(name) Return the value of the named header field."),
but when the header field is "name@example.com (Name)", I just
get "name@example.com" instead of "name@example.com (Name)"
(see code example below).

How can I get the value of the named header field "From",
as the documentation says?

main.py

import email
import email.policy

posting = email.message_from_bytes\
( b'From: Name <name@example.com>\r\n', policy=email.policy.default )
print( posting[ 'From' ])

posting = email.message_from_bytes\
( b'From: name@example.com (Name)\r\n', policy=email.policy.default )
print( posting[ 'From' ])

output (as is)

Name <name@example.com>
name@example.com

output (as wanted)

Name <name@example.com>
name@example.com (Name)

Re: [SOLVED]Just getting my From header field back?

<compat-20231130175031@ram.dialup.fu-berlin.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24584&group=comp.lang.python#24584

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.chmurka.net!weretis.net!feeder8.news.weretis.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram...@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: [SOLVED]Just getting my From header field back?
Date: 30 Nov 2023 16:58:01 GMT
Organization: Stefan Ram
Lines: 6
Expires: 1 Dec 2024 11:59:58 GMT
Message-ID: <compat-20231130175031@ram.dialup.fu-berlin.de>
References: <header-20231130172133@ram.dialup.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de B4KcQGjHd7S+F2bHYBWkRQSYyztQ3nMI3rl8NcvD3ZDr9F
Cancel-Lock: sha1:ypb5q6g57yBbxqp1+tKvFZ9LYTY= sha256:Sa6bS0yeJvsrZCd+6qRMnxSTzjw4TZ+5pgS1saoHUvk=
X-Copyright: (C) Copyright 2023 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE-1901, en-US, it, fr-FR
 by: Stefan Ram - Thu, 30 Nov 2023 16:58 UTC

ram@zedat.fu-berlin.de (Stefan Ram) writes:
>( b'From: Name <name@example.com>\r\n', policy=email.policy.default )

I need "email.policy.compat32".

Re: [SOLVED]Just getting my From header field back?

<ukah6r$1ess9$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24585&group=comp.lang.python#24585

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: nos...@please.ty (jak)
Newsgroups: comp.lang.python
Subject: Re: [SOLVED]Just getting my From header field back?
Date: Thu, 30 Nov 2023 18:36:26 +0100
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <ukah6r$1ess9$1@dont-email.me>
References: <header-20231130172133@ram.dialup.fu-berlin.de>
<compat-20231130175031@ram.dialup.fu-berlin.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 30 Nov 2023 17:36:27 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="9e6a94acdad18c3b5dd28ae69d3eb291";
logging-data="1536905"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19eNsK7uXZJSs69l7Sk7jFp"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.17.1
Cancel-Lock: sha1:Ef1WNfqRMCjn+KYATpeHX/m703Q=
In-Reply-To: <compat-20231130175031@ram.dialup.fu-berlin.de>
 by: jak - Thu, 30 Nov 2023 17:36 UTC

Stefan Ram ha scritto:
> ram@zedat.fu-berlin.de (Stefan Ram) writes:
>> ( b'From: Name <name@example.com>\r\n', policy=email.policy.default )
>
> I need "email.policy.compat32".
>
>

You could have found the complete string here too:

for h in posting._headers:
if h[0] == 'From':
print(h[1])

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor