diff --git a/phpBB/adm/admin_board.php b/phpBB/adm/admin_board.php
index 344ead2100..9ff1bb82e7 100644
--- a/phpBB/adm/admin_board.php
+++ b/phpBB/adm/admin_board.php
@@ -479,6 +479,10 @@ switch ($mode)
lang['BOARD_EMAIL_FORM']; ?>: lang['BOARD_EMAIL_FORM_EXPLAIN']; ?> |
/> lang['ENABLED']; ?> /> lang['DISABLED']; ?> |
+
+ lang['EMAIL_PACKAGE_SIZE']; ?>: lang['EMAIL_PACKAGE_SIZE_EXPLAIN']; ?> |
+ |
+
lang['CONTACT_EMAIL']; ?>: lang['CONTACT_EMAIL_EXPLAIN']; ?> |
|
diff --git a/phpBB/adm/admin_email.php b/phpBB/adm/admin_email.php
index c2c614a644..2a1d0b38ca 100644
--- a/phpBB/adm/admin_email.php
+++ b/phpBB/adm/admin_email.php
@@ -21,13 +21,8 @@
if (!empty($setmodules))
{
- if (!$auth->acl_get('a_email'))
- {
- return;
- }
-
- $module['GENERAL']['MASS_EMAIL'] = basename(__FILE__) . $SID;
-
+ $file = basename(__FILE__);
+ $module['GENERAL']['MASS_EMAIL'] = ($auth->acl_get('a_email')) ? "$file$SID" : '';
return;
}
@@ -43,52 +38,54 @@ if (!$auth->acl_get('a_email'))
trigger_error($user->lang['NO_ADMIN']);
}
-//
// Set some vars
-//
$message = '';
$subject = '';
-//
// Do the job ...
-//
if (isset($_POST['submit']))
{
- //
// Increase maximum execution time in case of a lot of users, but don't complain about it if it isn't
// allowed.
- //
@set_time_limit(1200);
$group_id = intval($_POST['g']);
- $sql = ($group_id != -1) ? "SELECT u.user_email FROM " . USERS_TABLE . " u, " . USER_GROUP_TABLE . " ug WHERE ug.group_id = $group_id AND ug.user_pending <> " . TRUE . " AND u.user_id = ug.user_id" : "SELECT user_email FROM " . USERS_TABLE;
+ if ($group_id > 0)
+ {
+ $sql = 'SELECT u.user_email, u.username, u.user_lang
+ FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . " ug
+ WHERE ug.group_id = $group_id
+ AND g.user_pending <> " . TRUE . "
+ AND u.user_id = ug.user_id";
+ }
+ else
+ {
+ $sql = 'SELECT user_email FROM ' . USERS_TABLE;
+ }
$result = $db->sql_query($sql);
- if (!($email_list = $db->sql_fetchrowset($g_result)))
+ $subject = stripslashes(trim($_POST['subject']));
+ $message = stripslashes(trim($_POST['message']));
+
+ if (!($row = $db->sql_fetchrow($result)))
{
- //
// Output a relevant GENERAL_MESSAGE about users/group
// not existing
- //
+ trigger_error($user->lang['GROUP_DOES_NOT_EXIST']);
}
- $subject = stripslashes($_POST['subject']);
- $message = stripslashes($_POST['message']);
-
- //
+
// Error checking needs to go here ... if no subject and/or
// no message then skip over the send and return to the form
- //
- $error = FALSE;
- if (!$error)
+
+ if ($subject != '' && $message != '')
{
include($phpbb_root_path . 'includes/emailer.'.$phpEx);
- //
+
// Let's do some checking to make sure that mass mail functions
// are working in win32 versions of php.
- //
if (preg_match('/[c-z]:\\\.*/i', getenv('PATH')) && !$config['smtp_delivery'])
{
// We are running on windows, force delivery to use
@@ -96,50 +93,60 @@ if (isset($_POST['submit']))
$config['smtp_delivery'] = 1;
$config['smtp_host'] = get_cfg_var('SMTP');
}
- $emailer = new emailer($config['smtp_delivery']);
+ $emailer = new emailer(true);
- $email_headers = 'From: ' . $config['board_email'] . "\n";
+ $extra_headers = 'X-AntiAbuse: Board servername - ' . $config['server_name'] . "\r\n";
+ $extra_headers .= 'X-AntiAbuse: User_id - ' . $user->data['user_id'] . "\r\n";
+ $extra_headers .= 'X-AntiAbuse: Username - ' . $user->data['username'] . "\r\n";
+ $extra_headers .= 'X-AntiAbuse: User IP - ' . $user->ip . "\r\n";
- $bcc_list = '';
- for($i = 0; $i < count($email_list); $i++)
+ $email_list = array();
+ $count = 0;
+ do
{
- $bcc_list .= (($bcc_list != '') ? ', ' : '') . $email_list[$i]['user_email'];
+ $email_list[$count]['email'] = $row['user_email'];
+ $email_list[$count]['name'] = $row['username'];
+ $email_list[$count]['lang'] = $row['user_lang'];
+ $count++;
+ }
+ while ($row = $db->sql_fetchrow($result));
+ $db->sql_freeresult($result);
+
+ foreach ($email_list as $addr)
+ {
+ $emailer->template('admin_send_email', $addr['lang']);
+
+ $emailer->subject($subject);
+ $emailer->headers($extra_headers);
+
+ $emailer->replyto($config['board_email']);
+ $emailer->to($addr['email'], $addr['name']);
+
+
+ $emailer->assign_vars(array(
+ 'SITENAME' => $config['sitename'],
+ 'CONTACT_EMAIL' => $config['board_contact'],
+ 'MESSAGE' => $message)
+ );
+
+ $emailer->send();
+ $emailer->reset();
}
- $email_headers .= "Bcc: $bcc_list\n";
-
- $email_headers .= 'Return-Path: ' . $userdata['board_email'] . "\n";
- $email_headers .= 'X-AntiAbuse: Board servername - ' . $server_name . "\n";
- $email_headers .= 'X-AntiAbuse: User_id - ' . $userdata['user_id'] . "\n";
- $email_headers .= 'X-AntiAbuse: Username - ' . $userdata['username'] . "\n";
- $email_headers .= 'X-AntiAbuse: User IP - ' . $user_ip . "\n";
-
- $emailer->use_template('admin_send_email');
- $emailer->email_address($config['board_email']);
- $emailer->set_subject($subject);
- $emailer->extra_headers($email_headers);
-
- $emailer->assign_vars(array(
- 'SITENAME' => $config['sitename'],
- 'BOARD_EMAIL' => $config['board_email'],
- 'MESSAGE' => $message)
- );
-
- $emailer->send();
- $emailer->reset();
-
- message_die(MESSAGE, $user->lang['Email_sent']);
+
+ $emailer->queue->save();
+ unset($email_list);
+
+ add_log('admin', 'LOG_MASS_EMAIL');
+ trigger_error($user->lang['EMAIL_SENT'], E_USER_NOTICE);
}
}
-//
// Initial selection
-//
-
-$sql = "SELECT group_id, group_name
- FROM ".GROUPS_TABLE;
+$sql = 'SELECT group_id, group_name
+ FROM ' . GROUPS_TABLE;
$result = $db->sql_query($sql);
-$select_list = '