You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
93 lines
2.6 KiB
PHTML
93 lines
2.6 KiB
PHTML
18 years ago
|
<?php
|
||
17 years ago
|
/**
|
||
|
* Postfix Admin
|
||
|
*
|
||
|
* LICENSE
|
||
|
* This source file is subject to the GPL license that is bundled with
|
||
|
* this package in the file LICENSE.TXT.
|
||
|
*
|
||
|
* Further details on the project are available at :
|
||
|
* http://www.postfixadmin.com or http://postfixadmin.sf.net
|
||
|
*
|
||
|
* @version $Id$
|
||
|
* @license GNU GPL v2 or later.
|
||
|
*
|
||
|
* File: broadcast-message.php
|
||
|
* Used to send a message to _ALL_ users with mailboxes on this server.
|
||
|
*
|
||
|
* Template File: broadcast-message.tpl
|
||
|
*
|
||
|
* Template Variables: -none-
|
||
|
*
|
||
|
* Form POST \ GET Variables:
|
||
|
*
|
||
|
* name
|
||
|
* subject
|
||
|
* message
|
||
|
*/
|
||
18 years ago
|
|
||
17 years ago
|
require_once('common.php');
|
||
17 years ago
|
|
||
|
authentication_require_role('global-admin');
|
||
|
|
||
|
$SESSID_USERNAME = authentication_get_username();
|
||
18 years ago
|
|
||
|
if ($_SERVER['REQUEST_METHOD'] == "POST")
|
||
|
{
|
||
17 years ago
|
if (empty($_POST['subject']) || empty($_POST['message']) || empty($_POST['name']))
|
||
18 years ago
|
{
|
||
|
$error = 1;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
17 years ago
|
$q = 'select username from mailbox union '.
|
||
|
'select goto from alias '.
|
||
|
'where goto not in (select username from mailbox)';
|
||
18 years ago
|
|
||
|
$result = db_query ($q);
|
||
|
if ($result['rows'] > 0)
|
||
|
{
|
||
17 years ago
|
$b_name = mb_encode_mimeheader( $_POST['name'], 'UTF-8', 'Q');
|
||
|
$b_subject = mb_encode_mimeheader( $_POST['subject'], 'UTF-8', 'Q');
|
||
|
$b_message = encode_base64($_POST['message']);
|
||
|
|
||
18 years ago
|
$i = 0;
|
||
17 years ago
|
while ($row = db_array ($result['result'])) {
|
||
18 years ago
|
$fTo = $row[0];
|
||
17 years ago
|
$fHeaders = 'To: ' . $fTo . "\n";
|
||
|
$fHeaders .= 'From: ' . $b_name . ' <' . $CONF['admin_email'] . ">\n";
|
||
|
$fHeaders .= 'Subject: ' . $b_subject . "\n";
|
||
|
$fHeaders .= 'MIME-Version: 1.0' . "\n";
|
||
|
$fHeaders .= 'Content-Type: text/plain; charset=UTF-8' . "\n";
|
||
|
$fHeaders .= 'Content-Transfer-Encoding: base64' . "\n";
|
||
18 years ago
|
|
||
|
$fHeaders .= $b_message;
|
||
|
|
||
17 years ago
|
if (!smtp_mail ($fTo, $CONF['admin_email'], $fHeaders))
|
||
18 years ago
|
{
|
||
|
$tMessage .= "<br />" . $PALANG['pSendmail_result_error'] . "<br />";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
17 years ago
|
$tMessage .= "<br />" . $PALANG['pSendmail_result_success'] . "<br />";
|
||
18 years ago
|
}
|
||
|
}
|
||
|
}
|
||
17 years ago
|
include ("templates/header.tpl");
|
||
|
include ("templates/menu.tpl");
|
||
18 years ago
|
echo '<p>'.$PALANG['pBroadcast_success'].'</p>';
|
||
17 years ago
|
include ("templates/footer.tpl");
|
||
18 years ago
|
}
|
||
|
}
|
||
|
|
||
|
if ($_SERVER['REQUEST_METHOD'] == "GET" || $error == 1)
|
||
|
{
|
||
17 years ago
|
include ("templates/header.tpl");
|
||
|
include ("templates/menu.tpl");
|
||
|
include ("templates/broadcast-message.tpl");
|
||
|
include ("templates/footer.tpl");
|
||
18 years ago
|
}
|
||
|
|
||
|
/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */
|
||
|
?>
|