File: qmailtest

package info (click to toggle)
qmail 1.02-1
  • links: PTS
  • area: non-free
  • in suites: slink
  • size: 2,268 kB
  • ctags: 1,721
  • sloc: ansic: 14,071; makefile: 1,923; sh: 583; perl: 452
file content (114 lines) | stat: -rw-r--r-- 2,874 bytes parent folder | download | duplicates (8)
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
#!/usr/bin/perl --
# Test message script for debian's Qmail distribution.
# Copyright 1994 Ian Jackson.  There is NO WARRANTY.
# See /usr/doc/qmail/copyright

$mayremote=1;
$|=1;

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

$halvestrand='linux-counter@uninett.no';

$visiblename='';
if (open(C,"/etc/qmail/defaulthost") || open(C,"/etc/qmail/me")) {
    $visiblename = <C> ;
    chomp $visiblename ;
}

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: Qmail 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`);
    $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
Qmail under a Debian Linux System.

//echo
//machine
name: $host
distribution: Debian 1.3.1
mailer: Qmail 1.01
//end
";
}

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

print "
Test message sent.

";

exit 0;