On 15/02/2021 09.50, Chris Green wrote: > It isn't clear from the documentation. Does email.message.get() care > about the case of the header it's getting? > > I checking mailing list mails and the "List-Id:" header is a bit > 'mixed', i.e. it can be List-Id:, or List-ID: or list-id:, will > email.message.get("List-Id:", "unknown") find all of them?
Case is (should be) irrelevant (as it is for most (parts of) Internet Protocols). Rather than the "Zen of Python", when it comes to IPs, "Postel's Law" applies (https://en.wikipedia.org/wiki/Robustness_principle). The library docs say it follows such. Web.Refs: https://docs.python.org/3/library/email.html <<< email — An email and MIME handling package Source code: Lib/email/__init__.py The email package is a library for managing email messages. It is specifically not designed to do any sending of email messages to SMTP (RFC 2821), NNTP, or other servers; those are functions of modules such as smtplib and nntplib. The email package attempts to be as RFC-compliant as possible, supporting RFC 5233 and RFC 6532... >>> https://tools.ietf.org/html/rfc6532.html <<< 3. Changes to Message Header Fields To permit non-ASCII Unicode characters in field values, the header definition in [RFC5322] is extended to support the new format. The following sections specify the necessary changes to RFC 5322's ABNF. The syntax rules not mentioned below remain defined as in [RFC5322]. Note that this protocol does not change rules in RFC 5322 for defining header field names. The bodies of header fields are allowed to contain Unicode characters, but the header field names themselves must consist of ASCII characters only. Also note that messages in this format require the use of the SMTPUTF8 extension [RFC6531] to be transferred via SMTP. ... >>> https://tools.ietf.org/html/rfc5322 <<< RFC 5322 Internet Message Format October 2008 2.2. Header Fields Header fields are lines beginning with a field name, followed by a colon (":"), followed by a field body, and terminated by CRLF. A field name MUST be composed of printable US-ASCII characters (i.e., characters that have values between 33 and 126, inclusive), except colon. A field body may be composed of printable US-ASCII characters as well as the space (SP, ASCII value 32) and horizontal tab (HTAB, ASCII value 9) characters (together known as the white space characters, WSP). A field body MUST NOT include CR and LF except when used in "folding" and "unfolding", as described in section 2.2.3. All field bodies MUST conform to the syntax described in sections 3 and 4 of this specification. ... >>> -- Regards, =dn -- https://mail.python.org/mailman/listinfo/python-list