From b934b083fcc82619f1a657f207ab5360844b0b66 Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Fri, 17 Aug 2007 15:14:16 +0000 Subject: [PATCH] broadcast-message.php: add ability for admins to email everyone, patch from Georgi Naplatanov - goshoo (via sf.net) git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@25 a1433add-5e2c-0410-b055-b7f2511e0802 --- admin/broadcast-message.php | 93 +++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 admin/broadcast-message.php diff --git a/admin/broadcast-message.php b/admin/broadcast-message.php new file mode 100644 index 00000000..8e0ebcef --- /dev/null +++ b/admin/broadcast-message.php @@ -0,0 +1,93 @@ + +// Copyright (c) 2002 - 2005 High5! +// Licensed under GPL for more info check GPL-LICENSE.TXT +// +// File: list-domain.php +// +// Template File: admin_list-domain.tpl +// +// Template Variables: +// +// -none- +// +// Form POST \ GET Variables: +// +// fUsername +// +// +require ("../variables.inc.php"); +require ("../config.inc.php"); +require ("../functions.inc.php"); +include ("../languages/" . check_language () . ".lang"); + +$SESSID_USERNAME = check_session (); +(!check_admin($SESSID_USERNAME) ? header("Location: " . $CONF['postfix_admin_url'] . "/main.php") && exit : '1'); + +if ($_SERVER['REQUEST_METHOD'] == "POST") +{ + $b_from = escape_string ($_POST['from']) ; + $b_subject = escape_string ($_POST['subject']) ; + $b_message = escape_string ($_POST['message']) ; + + if (strlen($b_subject) == 0 || strlen($b_message) == 0 || strlen($b_from) == 0) + { + $error = 1; + } + else + { + $q = "select username from mailbox union ". + "select goto from alias ". + "where goto not in (select username from mailbox)" ; + + $result = db_query ($q); + if ($result['rows'] > 0) + { + $i = 0; + while ($row = db_array ($result['result'])){ + $fHeaders = "To: " . $fTo . "\n"; + $fHeaders .= "From: " . $b_from . "\n"; + $fTo = $row[0]; + if (!empty ($PALANG['charset'])) + { + $fHeaders .= "Subject: " . encode_header ($b_subject, $PALANG['charset']) . "\n"; + $fHeaders .= "MIME-Version: 1.0\n"; + $fHeaders .= "Content-Type: text/plain; charset=" . $PALANG['charset'] . "\n"; + $fHeaders .= "Content-Transfer-Encoding: 8bit\n"; + } + else + { + $fHeaders .= "Subject: " . $b_subject . "\n\n"; + } + + $fHeaders .= $b_message; + + if (!smtp_mail ($fTo, $fFrom, $fHeaders)) + { + $tMessage .= "
" . $PALANG['pSendmail_result_error'] . "
"; + } + else + { + $tMessage .= "
" . $PALANG['pSendmail_result_succes'] . "
"; + } + } + } + include ("../templates/header.tpl"); + include ("../templates/admin_menu.tpl"); + echo '

'.$PALANG['pBroadcast_success'].'

'; + include ("../templates/footer.tpl"); + } +} + +if ($_SERVER['REQUEST_METHOD'] == "GET" || $error == 1) +{ + include ("../templates/header.tpl"); + include ("../templates/admin_menu.tpl"); + include ("../templates/broadcast-message.tpl"); + include ("../templates/footer.tpl"); +} + +/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ +?>