From 316afd5349c199a96bcd6635ffb1781efe5a3840 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Mon, 22 Jan 2007 12:23:04 +0000 Subject: [PATCH] mailing --- ND/Web/Pages/Mail.pm | 77 ++++++++++++++++++++++++++++++++++++++++++++ startup.pl | 3 ++ templates/mail.tmpl | 16 +++++++++ templates/skel.tmpl | 1 + 4 files changed, 97 insertions(+) create mode 100644 ND/Web/Pages/Mail.pm create mode 100644 templates/mail.tmpl diff --git a/ND/Web/Pages/Mail.pm b/ND/Web/Pages/Mail.pm new file mode 100644 index 0000000..98f5c2e --- /dev/null +++ b/ND/Web/Pages/Mail.pm @@ -0,0 +1,77 @@ +#************************************************************************** +# Copyright (C) 2006 by Michael Andreen * +# * +# This program is free software; you can redistribute it and/or modify * +# it under the terms of the GNU General Public License as published by * +# the Free Software Foundation; either version 2 of the License, or * +# (at your option) any later version. * +# * +# This program is distributed in the hope that it will be useful, * +# but WITHOUT ANY WARRANTY; without even the implied warranty of * +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +# GNU General Public License for more details. * +# * +# You should have received a copy of the GNU General Public License * +# along with this program; if not, write to the * +# Free Software Foundation, Inc., * +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * +#**************************************************************************/ + +package ND::Web::Pages::Mail; +use strict; +use warnings FATAL => 'all'; +use CGI qw/:standard/; +use Mail::Sendmail; + +use ND::Web::Forum; +use ND::Web::Include; + +use base qw/ND::Web::XMLPage/; + +$ND::Web::Page::PAGES{mail} = __PACKAGE__; + +sub render_body { + my $self = shift; + my ($BODY) = @_; + + my $DBH = $self->{DBH}; + + $self->{TITLE} = 'Mail members'; + + return $self->noAccess unless $self->isHC; + + my $groups = $DBH->prepare(q{SELECT gid,groupname FROM groups ORDER BY gid}); + $groups->execute; + my @groups; + while (my $group = $groups->fetchrow_hashref){ + push @groups,$group; + } + $BODY->param(Groups => \@groups); + + if (defined param('cmd')){ + 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}); + $emails->execute(param('group')); + my @emails; + while (my $email = $emails->fetchrow_hashref){ + push @emails,$email->{email}; + } + $ND::ERROR .= p (join ', ',@emails); + + my %mail = ( + smtp => 'ruin.nu', + To => (join ',',@emails), + From => 'NewDawn Command ', + 'Content-type' => 'text/plain; charset="UTF-8"', + Subject => param('subject'), + Message => param('message'), + ); + + if (sendmail %mail) { + $ND::ERROR .= p "Mail sent OK.\n" + }else { + $ND::ERROR .= p $Mail::Sendmail::error; + } + } + return $BODY; +} +1; diff --git a/startup.pl b/startup.pl index 77a3152..186b0c8 100644 --- a/startup.pl +++ b/startup.pl @@ -15,6 +15,8 @@ use GD::Graph::lines; use BBCode::Parser; +use Mail::Sendmail; + use ND; use ND::DB; use ND::Include; @@ -48,6 +50,7 @@ use ND::Web::Pages::Motd; use ND::Web::Pages::Forum; use ND::Web::Pages::Settings; use ND::Web::Pages::Graph; +use ND::Web::Pages::Mail; diff --git a/templates/mail.tmpl b/templates/mail.tmpl new file mode 100644 index 0000000..7813b7a --- /dev/null +++ b/templates/mail.tmpl @@ -0,0 +1,16 @@ + + +

+
+ +
Intel + Subject: +
To: +
+ +
+
diff --git a/templates/skel.tmpl b/templates/skel.tmpl index c4d4174..6ae0691 100644 --- a/templates/skel.tmpl +++ b/templates/skel.tmpl @@ -67,6 +67,7 @@
  • Member Intel
  • Alliance resources
  • Planet Naps
  • +
  • Mail
  • -- 2.39.2