1 |
wakaba |
1.1 |
|
2 |
|
|
=head1 NAME
|
3 |
|
|
|
4 |
|
|
Message::Tool -- Tools used with Message::* Perl Modules
|
5 |
|
|
|
6 |
|
|
=head1 DESCRIPTION
|
7 |
|
|
|
8 |
|
|
Useful functions that are intended to be used with Message::* Perl Modules.
|
9 |
|
|
|
10 |
|
|
Note that there is Message::Util, very similar named module,
|
11 |
|
|
but its functions are used by Message::* Perl Modules internally.
|
12 |
|
|
|
13 |
|
|
=cut
|
14 |
|
|
|
15 |
|
|
package Message::Tool;
|
16 |
|
|
use strict;
|
17 |
|
|
use vars qw($VERSION);
|
18 |
|
|
$VERSION=do{my @r=(q$Revision: 1.18 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r};
|
19 |
|
|
|
20 |
|
|
sub mail_downgrade ($%) {
|
21 |
|
|
my $msg = shift;
|
22 |
|
|
my %option = @_;
|
23 |
|
|
my $hdr = $msg->header;
|
24 |
|
|
## "<" in display-name of From: field
|
25 |
|
|
my $from = $hdr->field ('from', -new_item_unless_exist => 0);
|
26 |
|
|
## BUG: Non-ASCII 0x3A such as in JIS X 0208 are not supported.
|
27 |
|
|
if (ref $from && $from->item (0, -by => 'index')->display_name =~ /</) {
|
28 |
|
|
my $buggy = 0;
|
29 |
|
|
my @to = @{ $option{destination} };
|
30 |
|
|
## TODO: Support Resent-* fields
|
31 |
|
|
@to = ($hdr->field ('to')->addr_spec,
|
32 |
|
|
$hdr->field ('cc')->addr_spec,
|
33 |
|
|
$hdr->field ('bcc')->addr_spec) unless @to > 0;
|
34 |
|
|
for (@to) {
|
35 |
|
|
$buggy = 1 if /\@jp-[a-z]\.ne\.jp$/i;
|
36 |
|
|
}
|
37 |
|
|
$from->item (0, -by => 'index')->option (output_display_name => 0) if $buggy;
|
38 |
|
|
}
|
39 |
|
|
}
|
40 |
|
|
|
41 |
|
|
=head1 LICENSE
|
42 |
|
|
|
43 |
|
|
Copyright 2002 wakaba E<lt>w@suika.fam.cxE<gt>.
|
44 |
|
|
|
45 |
|
|
This program is free software; you can redistribute it and/or modify
|
46 |
|
|
it under the terms of the GNU General Public License as published by
|
47 |
|
|
the Free Software Foundation; either version 2 of the License, or
|
48 |
|
|
(at your option) any later version.
|
49 |
|
|
|
50 |
|
|
This program is distributed in the hope that it will be useful,
|
51 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
52 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
53 |
|
|
GNU General Public License for more details.
|
54 |
|
|
|
55 |
|
|
You should have received a copy of the GNU General Public License
|
56 |
|
|
along with this program; see the file COPYING. If not, write to
|
57 |
|
|
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
58 |
|
|
Boston, MA 02111-1307, USA.
|
59 |
|
|
|
60 |
|
|
=head1 CHANGE
|
61 |
|
|
|
62 |
|
|
See F<ChangeLog>.
|
63 |
|
|
$Date: 2002/07/21 03:26:02 $
|
64 |
|
|
|
65 |
|
|
=cut
|
66 |
|
|
|
67 |
|
|
1;
|