Subject: | Quoting the Phrase |
Hi Casey. It would be good if this module automatically quoted the
phrase part of an e-mail address if necessary, that is putting it in
quote marks if it doesn't consist only of certain characters.
I have a DB with names in one field and e-mail address in another. I'd
like to combine them (for sending them mail), but using Email::Address
can currently yield invalid e-mail addresses. For example this is fine:
% perl -MEmail::Address -wle 'print Email::Address->new(q[Homer J Simpson], q[homer@example.org])->format'
Homer J Simpson <homer@example.org>
But put a dot in there and it's broken:
% perl -MEmail::Address -wle 'print Email::Address->new(q[Homer J. Simpson], q[homer@example.org])->format'
Homer J. Simpson <homer@example.org>
Mail::Address does this correctly -- just swapping the module name
in the above 2 examples gives:
% perl -MMail::Address -wle 'print Mail::Address->new(q[Homer J Simpson], q[homer@example.org])->format'
Homer J Simpson <homer@example.org>
and:
% perl -MMail::Address -wle 'print Mail::Address->new(q[Homer J. Simpson], q[homer@example.org])->format'
"Homer J. Simpson" <homer@example.org>
I've had a quick look at the quoting code in Mail::Address, and it
looks like you could steal it. I haven't worked out whether it'd be
better to do the quoting on input or output. I only need it for
manually created addresses, not those being parsed from somewhere; if
you do this for the latter too then you'll have to make sure you
allow for any quotes that are already in there, to avoid risking
quoting stuff twice ("\"Homer J. Simpson\"" -- yuck!).
Best wishes.
Smylers