Article View: fj.net.mime
Article #196Re: Filter to attach text to an existing message?
From: Kazuhiro Sasayama
Date: Thu, 29 May 1997 00:00
Date: Thu, 29 May 1997 00:00
61 lines
2541 bytes
2541 bytes
>>>>> On Sun, 18 May 1997 08:39:16 GMT, Kazuhiro Sasayama <kaz@hypercore.co.jp> said:
Kaz> $B$$$o$f$k(B Unix $B4D6-$G!"(B RFC822/MIME $B7A<0$NF~NO$KBP$7$F!"G$0U$N8GDj%F%-(B
Kaz> $B%9%H$rE:IU$7$?(B multipart $B%a%C%;!<%8$r=PNO$9$k%U%#%k%?!<$rC5$7$F$$$^$9!#(B
Kaz> $B$b$7=j:_$J$I$4B8$8$G$7$?$i!"$*65$($/$@$5$$!#(B
$B$@$l$b65$($F$/$l$J$+$C$?$N$G!"E,Ev$K:n$C$F$_$^$7$?!#<{MW$,$"$k$h$&$J$i!"(B
$B$b$&>/$7@0M}$7$F(B fj.sources $B$K$G$b=P$9$D$b$j$G$$$^$9!#(B
Perl 5 + MailTools $BMQ$G$9!#(B
#! /usr/bin/perl --
# mimeattach - attach a MIME message to a message.
# Copyright (C) 1997 Hypercore Software Design, Ltd.
use Mail::Internet;
$mail = new Mail::Internet \*STDIN;
$boundary = "---" . time;
# Copy Content-* headers to body.
@content_tags = grep /^Content-/i, $mail->head->tags;
unshift @{$mail->body}, "\n";
foreach $tag (@content_tags) {
$value = $mail->head->get ($tag);
unshift @{$mail->body}, "$tag: $value";
}
# Add the first boundary.
unshift @{$mail->body}, "--$boundary\n";
# Add part.
push @{$mail->body}, "\n--$boundary\n";
while (<>) {
push @{$mail->body}, $_;
}
# Add the final boundary.
push @{$mail->body}, "\n--$boundary--\n";
# Add MIME headers.
$mail->head->replace ("MIME-Version", "1.0");
$mail->head->replace ("Content-Type", "multipart/mixed; boundary=\"$boundary\"");
# Adjust Content-Transfer-Encoding.
# A multipart message cannot be quoted-printable or base64.
$content_transfer_encoding = $mail->head->get ('Content-Transfer-Encoding');
if ($content_transfer_encoding =~ /^quoted-printable$/i
|| $content_transfer_encoding =~ /^base64$/i) {
$mail->head->replace ("Content-Transfer-Encoding", "7bit");
}
# Output.
$mail->print;
--
Kaz Sasayama, the designer of Hyperplay, working at
Hypercore Software Design, Ltd. <URL:http://www.spice.or.jp/%7Ehypercor/>.
PGP key fingerprint = 53 71 54 56 FB 3D 76 0B 92 5D 32 40 C5 34 38 00
Technical Details
Message-ID:
<2m3er6wqbk.fsf@lilia.hypercore.co.jp>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<2m67whfa2z.fsf@lilia.hypercore.co.jp>Show Full Headers
Complete Article Headers
X-Google-Language: Japanese,JIS X-Google-Thread: 100bbf,6bffb1b619f0a027 X-Google-Attributes: gid100bbf,public From: Kazuhiro Sasayama <kaz@hypercore.co.jp> Subject: Re: Filter to attach text to an existing message? Date: 1997/05/29 Message-ID: <2m3er6wqbk.fsf@lilia.hypercore.co.jp> X-Deja-AN: 244697443 Sender: kaz@hypercore.co.jp (Kazuhiro Sasayama) References: <2m67whfa2z.fsf@lilia.hypercore.co.jp> Organization: Hypercore Software Design, Ltd., Nagoya, Japan <URL:http://www.spice.or.jp/~hypercor/> X-Attribution: Kaz Newsgroups: fj.net.mime