On Saturday 17 September 2016 00:37:40 Ricardo Signes wrote: > * p...@cpan.org [2016-09-12T03:26:52] > > > And as I wrote if Email::MIME is not good place, then what about > > other modules like Email::MIME::Header::Address (or invent other > > name) which will use Address parse/format functions and will also > > do that MIME encode/decode procedure? We can maybe add classes > > also for other headers (like you suggested for DKIM signatures, > > etc...). > > I had started to write a lot of reply on the previous parts of your > email, but I think that this is the only part that really matters in > the end. Yes, I think some thing like that is sufficient. In the > end, I think what's best is: > > * a thing that can take a raw (encoded) header string and give you an > object * ...which is an object with access to the header's > structured data * ...which you can turn back into a raw header to > store as needed > > With that facility, people can plug in (header => class) > configuration and things just go. We can start off suggesting, for > example, an address one.
Ok, so first step can be support passing blessed objects with as_mime_string() method into $email->header_str_set(). Object's as_mime_string() will be responsible for producing correct MIME-encoded header value Next, I believe we agreed on $email->header_as_obj($name, $class) method which will return object for header name of class. It can use e.g. $class->from_mime_string() method for creating object. (Plus there will be some registration mechanism to predefine $name => $class mapping, so $class argument does not needs to be mandatory). I think these two parts should be enough for Email::MIME API from user of Email::MIME perspective. And I would propose new module (e.g. Email::MIME::Header::AddressList) which will be in Email::MIME distribution and will represent list of Email::Address::XS objects with own implementation of ->as_mime_string() and ->from_mime_string() methods. That could be used for passing list/groups of Email::Address::XS objects into Email::MIME and also get them via header_as_obj() API. $class->from_mime_string() will take raw MIME encoded string and returns new object of $class (which will have decoded string parts) $object->as_mime_string() will convert (Unicode) $object into raw MIME encoded string It is OK for you?