File: forwd_demo.PL

package info (click to toggle)
libmailtools-perl 2.13-1~bpo70%2B1
  • links: PTS
  • area: main
  • in suites: wheezy-backports
  • size: 416 kB
  • sloc: perl: 2,213; makefile: 50
file content (61 lines) | stat: -rw-r--r-- 1,171 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# This -*- perl -*- script makes the forwd_demo script
# $Id: forwd_demo.PL,v 1.2 1997/01/16 20:43:34 gbarr Exp $

use Config;
use Cwd;

$script = "./forwd_demo";
unlink($script);

open MIR, ">$script" or die "open for writing $script: $!";
print MIR $Config{'startperl'}," -w\n";
$cwd = Cwd::getcwd();
#print MIR "use lib qw($cwd/blib);\n";
print MIR <DATA>; 
chmod(0755, $script);

__DATA__
use Mail::Internet;

@mail = <>;

$mail = Mail::Internet->new(\@mail);

$mail->remove_sig;
$mail->tidy_body;

@reply = ();
if(open(HDR,"$ENV{HOME}/.mailhdr")) {
 @reply = <HDR>;
 close(HDR);
}

$rply = Mail::Internet->new(\@reply);

$subject = $mail->get('Subject');

$rply->replace('To', "");
$rply->replace('Cc', "");
$rply->replace('Subject',$subject);

$rply->body($body = $mail->body);

unshift @{$body},"---------- Begin Included Message ----------\n";
push    @{$body},"----------- End Included Message -----------\n";

$file = "/tmp/reply.$$";

open(FILE,">$file") || die "Cannot open $file:$!\n";

$rply->print(\*FILE);

close(FILE);

$editor = $ENV{"EDITOR"} || "/usr/bin/nvi";

warn "$editor :$!\n" if (system("$editor $file"));

unlink($file,$file . '%');

exit 0;