File: smailtest

package info (click to toggle)
smail 3.2.0.115-7.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 5,192 kB
  • ctags: 4,249
  • sloc: ansic: 48,248; sh: 4,321; makefile: 2,074; perl: 1,147; awk: 884; yacc: 428; sed: 256; xml: 57
file content (120 lines) | stat: -rw-r--r-- 3,060 bytes parent folder | download | duplicates (2)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/usr/bin/perl --
# Test message script for debian's Smail distribution.
# Copyright 1994 Ian Jackson.  There is NO WARRANTY.
# See /usr/doc/smail/copyright or type smail -bC for more information.

$mayremote=1;
$|=1;

$_= shift(@ARGV);
if ($_ eq '--allowremote') { $mayremote=1; }
elsif ($_ eq '--localonly') { $mayremote=0; }
else { die "usage: smailtest --localonly | --allowremote\n"; }

$halvestrand='linux-counter@counter.li.org';

$visiblename='';
if (open(C,"/etc/smail/config")) {
    while (<C>) {
        next unless s/^visible_name=//;
        s/\s+$//; s/^\s+//;
        $visiblename= $_;
        last;
    }
}

if ($mayremote) {
    $msg= length($visiblename)
        ?
"
Would you like to send a test message now ?  Select one of:

 Return or Y  Yes, test offsite delivery with a message to Harald Alvestrand's
               Linux Counter project - you should then receive an autoreply
               to postmaster\@$visiblename.

              Do not use this option until mail routing to your machine has
               been properly enabled, please !

     L        Just a local message from root\@$visiblename
               to postmaster\@$visiblename.

     N        No, thanks.  (You can do this later using /usr/sbin/smailtest.)

Send a test message now ?  (y/l/n)    "
        :
"
Would you like to send a test message now ?  Select one of:

 Return or Y  Yes, test offsite delivery with a message to Harald Alvestrand's
               Linux Counter project - you should then receive an autoreply.

              Do not use this option until mail routing to your machine has
               been properly enabled, please !

     L        Just a local message to \`root' from \`postmaster'.

     N        No, thanks.  (You can do this later using /usr/sbin/smailtest.)

Send a test message now ?  (y/l/n)    ";
    $accept= 'yln';
} else {
    $msg=
"Would you like to send a test message from `root' to `postmaster' ?
Send a test message now ?  (y/n)     ";
    $accept= 'yn';
}

do {
    print $msg;
    $_= <STDIN>;
    s/\s+$//; s/^\s+//;
} while (!m/^[$accept]?$/i);

exit 0 if m/^n/i;

chop($d=`date`);

if (!$mayremote || m/^l/i) {
    $message=
"From: root
To: postmaster
Subject: Smail system installation test message

This is the test message you were promised.
It was sent at $d.

If you want to send a remote test message run \`smailtest' again.
";
} else {
    chop($host=`hostname --fqdn`);
    chop($debvers=`cat /etc/debian_version`);
    chop($smailvers=`/usr/sbin/smail -V`);
    $message=
"From: postmaster
To: $halvestrand
Subject: Linux mail system installation auto-registration/test

This message was sent at $d
to test this system's mailer and to register its use of
Smail under a Debian Linux System.

//echo
//machine
name: $host
distribution: Debian $debvers
mailer: $smailvers
//end
";
}

open(P,"|/usr/sbin/sendmail -oem -odi -t -oi") || die "pipe to smail: $!\n";
print(P $message) || die "write to smail: $!\n";
$!=0; close(P); $? && die "smail failed $?/$!\n";

print "
Test message sent.

";

exit 0;