[ic] email options
David Christensen
david at endpoint.com
Mon Mar 16 06:41:40 UTC 2009
On Mar 13, 2009, at 6:17 AM, Davor Ocelic wrote:
> On Thu, 12 Mar 2009 21:52:18 -0500
> David Christensen <david at endpoint.com> wrote:
>
>>
>> On Mar 12, 2009, at 9:37 PM, Peter wrote:
>>
>>> On 03/12/2009 07:21 PM, David Christensen wrote:
>>>> I'm trying to figure out where to add support for the proper
>>>> encoding of headers and body encoding, and I see there are a
>>>> number of possible
>>>> candidates:
>>>>
>>>> email.tag
>>>> email_raw.tag
>>>> Vend::Email::tag_mail
>>>> Vend::Email::tag_mime_lite_email
>>>>
>>>> ...and probably some more I have missed. Are these all active/
>>>> supported methods of email sending? Are there any that I'm
>>>> missing? Is there an overview of what each is intended to do and
>>>> how they differ?
>>>
>>> Davor once worked on an Email.pm file which everything was supposed
>>> to channel through. It would probably be a good idea to finish
>>> that work up, route all the other various email tags and functions
>>> through that, then you just have to update the one file.
>>
>>
>> Sounds good. Based on my inspection of the history, this appears to
>> be the Vend::Email module, so I'll see about making the various
>> *.tag just be RoutineMaps to the corresponding routine in
>> Vend::Email.
>
> That's right. Stefan was also involved in the work, and he committed
> the Email.pm module.
>
> I already created a diff that adjusts all email sending functions
> in IC (including tags) -- the patch should be sitting in Racke's
> archive, it just wasn't applied before email header encoding was
> finished.
Here's a first pass at the email header encoding, using the Encode
module instead of MIME::EncWords. Review appreciated:
----
diff --git a/lib/Vend/Email.pm b/lib/Vend/Email.pm
index cd7a6b2..0eac276 100644
--- a/lib/Vend/Email.pm
+++ b/lib/Vend/Email.pm
@@ -31,10 +31,6 @@
# Copies of some of the old functions are also included (and modified
# to fit the picture), to be called when no useful wrapper code
# can be made.
-#
-# TODO:
-# Header Word-encoding
-#
package Vend::Email;
@@ -47,6 +43,8 @@ BEGIN {
};
}
+use Encode;
+
use Mail::Address qw//;
use MIME::QuotedPrint qw//; # Used by default
use MIME::Base64 qw//; # For user-specified encodings
@@ -157,20 +155,19 @@ sub tag_mime_lite_email {
$intercept = $_;
}
- # XXX Header word-encoding: currently inactive block.
+ # Header word-encoding:
# All e-mail headers need to be Word-Encoded if they contain non-
ASCII.
# Field names themselves must not be encoded, they're always in
English.
# Header_encoding can be 1|y|none|q|b|a|s:
# - '1' and 'y' are our special synonyms for 'q'.
# - 'none' is our special value for no encoding
- # - the rest are actual supported values by MIME::EncWords.
- #if ( $_ = delete $opt->{'header_encoding'} ) {
- # $hdr_encoding = $_;
- #}
- #if (! $hdr_encoding or $hdr_encoding =~ /1|y/i ) {
- # $hdr_encoding = 'q';
- #}
- #$hdr_encoding eq 'none' and $hdr_encoding = '';
+ if ( $_ = delete $opt->{'header_encoding'} ) {
+ $hdr_encoding = $_;
+ }
+ if (! $hdr_encoding or $hdr_encoding =~ /1|y/i ) {
+ $hdr_encoding = 'q';
+ }
+ $hdr_encoding eq 'none' and $hdr_encoding = '';
# Interpolate/reparse
($interpolate, $reparse, $hide) = (
@@ -491,12 +488,23 @@ sub tag_mime_lite_email {
#
# Add headers to $msg object
for my $hdr (@headers) {
+ my $header_value;
# [0] is name, [1] is value.
$$hdr[0] =~ s/_/-/g;
# Finally, header can go in.
- $msg->add($$hdr[0], $$hdr[1]);
+ if ($hdr_encoding) {
+ $header_value = Encode::encode(
+ $hdr_encoding eq 'q' ? 'MIME-Header-Q' : 'MIME-Header-
B',
+ $$hdr[1]
+ );
+ }
+ else {
+ $header_value = $$hdr[1];
+ }
+
+ $msg->add($$hdr[0], $header_value);
}
#
----
Regards,
David
--
David Christensen
End Point Corporation
david at endpoint.com
212-929-6923
http://www.endpoint.com/
More information about the interchange-users
mailing list