import rt 2.0.14
[freeside.git] / FS / bin / freeside-email
1 #!/usr/bin/perl -Tw
2
3 use strict;
4 use FS::UID qw(adminsuidsetup);
5 use FS::Conf;
6 use FS::Record qw(qsearch);
7 use FS::svc_acct;
8
9 &untaint_argv;  #what it sounds like  (eww)
10 my $user = shift or die &usage;
11
12 adminsuidsetup $user;
13
14 my $conf = new FS::Conf;
15 my $domain = $conf->config('domain');
16
17 my @svc_acct = qsearch('svc_acct', {});
18 my @usernames = map $_->username, @svc_acct;
19 my @emails = map "$_\@$domain", @usernames;
20
21 print join("\n", @emails), "\n";
22
23 # subroutines
24
25 sub untaint_argv {
26   foreach $_ ( $[ .. $#ARGV ) { #untaint @ARGV
27     #$ARGV[$_] =~ /^([\w\-\/]*)$/ || die "Illegal arguement \"$ARGV[$_]\"";
28     # Date::Parse
29     $ARGV[$_] =~ /^(.*)$/ || die "Illegal arguement \"$ARGV[$_]\"";
30     $ARGV[$_]=$1;
31   }
32 }
33
34 sub usage {
35   die "Usage:\n\n  freeside-email user\n";
36 }
37
38 =head1 NAME
39
40 freeside-email - Prints email addresses of all users on STDOUT
41
42 =head1 SYNOPSIS
43
44   freeside-email user
45
46 =head1 DESCRIPTION
47
48 Prints the email addresses of all customers on STDOUT, separated by newlines.
49
50 user: From the mapsecrets file - see config.html from the base documentation
51
52 =head1 VERSION
53
54 $Id: freeside-email,v 1.1 2001-05-15 07:52:34 ivan Exp $
55
56 =head1 BUGS
57
58 =head1 SEE ALSO
59
60 =cut
61