1 |
dpavlin |
1.1 |
#!/usr/local/bin/perl -w |
2 |
|
|
|
3 |
|
|
# usage: cat .htusers | sendlogins.pl http://docmain.domain.com/ |
4 |
|
|
|
5 |
dpavlin |
1.2 |
#my $debug=1; |
6 |
dpavlin |
1.1 |
|
7 |
|
|
my $in_mail=$0; |
8 |
|
|
$in_mail=~s/\.pl/.txt/; |
9 |
|
|
|
10 |
|
|
my $url=$ARGV[0]; |
11 |
|
|
|
12 |
dpavlin |
1.3 |
if (! $url) { |
13 |
|
|
print STDERR "To send announcement to all users in .htusers file use\n"; |
14 |
|
|
print STDERR "$0 http://docman.site.com/ < .htusers\n"; |
15 |
|
|
exit 1; |
16 |
|
|
} |
17 |
|
|
|
18 |
dpavlin |
1.1 |
$|++; |
19 |
|
|
|
20 |
|
|
while(<STDIN>) { |
21 |
|
|
chomp; |
22 |
|
|
chomp; |
23 |
|
|
|
24 |
|
|
($login,$fullname,undef,$email) = split(/:/,$_); |
25 |
|
|
my $host=$email; |
26 |
dpavlin |
1.2 |
$host=~s/^[^@]*@//g; |
27 |
dpavlin |
1.1 |
|
28 |
|
|
if (defined $debug) { |
29 |
|
|
open(MAIL,">> /tmp/mailfoo") || die "$!"; |
30 |
|
|
} else { |
31 |
|
|
open(MAIL,"| /usr/lib/sendmail -t") || die "sendmail: $!"; |
32 |
|
|
} |
33 |
|
|
|
34 |
|
|
print MAIL "To: $fullname <$email>\n"; |
35 |
|
|
|
36 |
|
|
open(IN,"$in_mail") || die "in mail: $!"; |
37 |
|
|
while(<IN>) { |
38 |
|
|
chomp; |
39 |
|
|
chomp; |
40 |
|
|
s/##login##/$login/g; |
41 |
|
|
s/##url##/$url/g; |
42 |
|
|
s/##pop3host##/$host/g; |
43 |
|
|
print MAIL "$_\n"; |
44 |
|
|
} |
45 |
|
|
close(IN); |
46 |
|
|
close(MAIL); |
47 |
|
|
print "." if ($debug); |
48 |
|
|
} |
49 |
|
|
|