1 #**************************************************************************
2 # Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu> *
4 # This program is free software; you can redistribute it and/or modify *
5 # it under the terms of the GNU General Public License as published by *
6 # the Free Software Foundation; either version 2 of the License, or *
7 # (at your option) any later version. *
9 # This program is distributed in the hope that it will be useful, *
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 # GNU General Public License for more details. *
14 # You should have received a copy of the GNU General Public License *
15 # along with this program; if not, write to the *
16 # Free Software Foundation, Inc., *
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 #**************************************************************************/
20 package ND::Web::Pages::Mail;
22 use warnings FATAL => 'all';
23 use CGI qw/:standard/;
29 use base qw/ND::Web::XMLPage/;
31 $ND::Web::Page::PAGES{mail} = __PACKAGE__;
37 my $DBH = $self->{DBH};
39 $self->{TITLE} = 'Mail members';
41 return $self->noAccess unless $self->isHC;
43 my $groups = $DBH->prepare(q{SELECT gid,groupname FROM groups ORDER BY gid});
46 while (my $group = $groups->fetchrow_hashref){
49 $BODY->param(Groups => \@groups);
51 if (defined param('cmd')){
52 my $emails = $DBH->prepare(q{SELECT email FROM users WHERE (uid IN (SELECT uid FROM groupmembers WHERE gid = $1) OR $1 = -1) AND email is not null});
53 $emails->execute(param('group'));
55 while (my $email = $emails->fetchrow_hashref){
56 push @emails,$email->{email};
58 $ND::ERROR .= p (join ', ',@emails);
62 BCC => (join ',',@emails),
63 From => 'NewDawn Command <nd@ruin.nu>',
64 'Content-type' => 'text/plain; charset="UTF-8"',
65 Subject => param('subject'),
66 Message => param('message'),
70 $ND::ERROR .= p "Mail sent OK.\n"
72 $ND::ERROR .= p $Mail::Sendmail::error;