mailparse icon indicating copy to clipboard operation
mailparse copied to clipboard

Add functions to parse List-Id

Open link2xt opened this issue 2 years ago • 2 comments

List-Id is defined in RFC 2919.

A header may look like this (two lines, second line starts with a tabulation):

List-Id: "Mailing list for \"Foo Bar\""                                    
    <foo-bar.lists.example.net>  

It should be possible to extract so-called "phrase" part of the header (Mailing list for "Foo bar"). Existing function addrparse_header does not work because it returns MailListAddr. An attempt to extract an address with extract_singe_info fails to parse the field with an error "Invalid address found: must contain a '@' symbol".

So the field cannot be parsed as an address list and a dedicated parser for List-Id is needed.

link2xt avatar May 16 '23 15:05 link2xt

Hi, sorry for the delay here. I don't think I'll have time in the foreseeable future to implement this but I would take a PR. Can probably reuse most of the code from the existing header parser but have separate types for holding the parsed results and returning them.

staktrace avatar May 24 '23 03:05 staktrace

@link2xt mail-parser implements RFC 2919 (among others).

xandkar avatar Jul 31 '24 01:07 xandkar