Skip Menu |

This queue is for tickets about the Mail-Box CPAN distribution.

Report information
The Basics
Id: 52119
Status: resolved
Priority: 0/
Queue: Mail-Box

People
Owner: Nobody in particular
Requestors: icestar [...] inbox.ru
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 2.092
Fixed in: (no value)



Subject: Problems with Mail::Message::Field::Full module
First of all it doesn't work with utf-8 strings, but maybe this problem of Mail::Message::Field::Address module. my $to = 'Simple Example <dima@mailbox.ru>'; my $field = Mail::Message::Field::Full->new('To' => $to, charset => 'utf-8', encoding => 'B'); Another problem is that it doesn't pass options charset and encoding to constructor of Mail::Message::Field::Address module.
Subject: Re: [rt.cpan.org #52119] Problems with Mail::Message::Field::Full module
Date: Fri, 27 Nov 2009 11:54:32 +0100
To: Dmitry Bigunyak via RT <bug-Mail-Box [...] rt.cpan.org>
From: Mark Overmeer <solutions [...] overmeer.net>
* Dmitry Bigunyak via RT (bug-Mail-Box@rt.cpan.org) [091127 10:35]: Show quoted text
> Fri Nov 27 05:35:04 2009: Request 52119 was acted upon. > Transaction: Ticket created by Alien > Queue: Mail-Box > Subject: Problems with Mail::Message::Field::Full module > > First of all it doesn't work with utf-8 strings, but maybe this problem > of Mail::Message::Field::Address module.
Maybe, we need an decode somewhere (I am a poor, unknowing latin1 user myself) Show quoted text
> my $to = 'Simple Example <dima@mailbox.ru>'; > my $field = Mail::Message::Field::Full->new('To' => $to, charset => > 'utf-8', encoding => 'B'); > > Another problem is that it doesn't pass options charset and encoding to > constructor of Mail::Message::Field::Address module.
It does: Mail::Message::Field::Full::new says: sub new($;$$@) { my $class = shift; ... my %args = @_; ... return $class->SUPER::new(%args, name => $name, body => $body) if $class ne __PACKAGE__; ... $myclass->SUPER::new(%args, name => $name, body => $body); } So, the additional %args are passed on, but something else may be wrong. -- MarkOv ------------------------------------------------------------------------ Mark Overmeer MSc MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net
Ok. I need to make simple thing: create "To" message field. This code now doesn't work: my $to = 'Простой Тест <simple@test.ru>'; my $field = Mail::Message::Field::Full->new('To' => $to, charset => 'utf-8', encoding => 'B'); I know two solutions: First. my ($ma) = Mail::Address->parse($to); my $to_address = Mail::Message::Field::Address->coerce($ma, charset => $charset, encoding => 'B'); my $field = Mail::Message::Field::Full->new('to' => $to_address); Second. my $to_address = Mail::Message::Field::Address->new(address => 'simple@test.ru', phrase => "Простой Тест", charset => 'utf-8', encoding => 'B'); my $field = Mail::Message::Field::Full->new('to' => $to_address); But I don't like them. Can you suggest another away?
Subject: Re: [rt.cpan.org #52119] Problems with Mail::Message::Field::Full module
Date: Fri, 27 Nov 2009 13:07:34 +0100
To: Dmitry Bigunyak via RT <bug-Mail-Box [...] rt.cpan.org>
From: Mark Overmeer <mark [...] overmeer.net>
* Dmitry Bigunyak via RT (bug-Mail-Box@rt.cpan.org) [091127 11:11]: Show quoted text
> Queue: Mail-Box > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=52119 > > > Ok. I need to make simple thing: create "To" message field. This code > now doesn't work: > my $to = 'Простой Тест <simple@test.ru>'; > my $field = Mail::Message::Field::Full->new('To' => $to, charset => > 'utf-8', encoding => 'B');
There is a very good reason for this not to work: on various parts in the "To" field there are different rules about character sets and how to encode them. Even the rules for one email addresses phrase and comment components are quite different. Show quoted text
> I know two solutions: > First. > my ($ma) = Mail::Address->parse($to); > my $to_address = Mail::Message::Field::Address->coerce($ma, charset => > $charset, encoding => 'B'); > my $field = Mail::Message::Field::Full->new('to' => $to_address);
No, above is not a correct solution: you start with a non-compliant email address. It's bad behavior of Mail::Address to accept it. Probably because Mail::Address date from before "MIME" was invented, and everything was always ASCII. Show quoted text
> Second. > my $to_address = Mail::Message::Field::Address->new(address => > 'simple@test.ru', phrase => "Простой Тест", charset => 'utf-8', > encoding => 'B'); > my $field = Mail::Message::Field::Full->new('to' => $to_address);
Well, doing encodings right is very difficult. That's why a lot of people use the non-::Full headers and ignore these encodings (the end-user sees them not-decoded) If you have to do above a few times, then simply wrap it in a function which suites your specific needs. -- Regards, MarkOv ------------------------------------------------------------------------ Mark Overmeer MSc MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net
Thank you for explanation.
not an error