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 = ''; if ($row = $db->sql_fetchrow($result)) { do @@ -150,32 +157,33 @@ if ($row = $db->sql_fetchrow($result)) } $select_list .= ''; -adm_page_header($user->lang['Mass_Email']); +adm_page_header($user->lang['MASS_EMAIL']); ?> -

lang['Mass_Email']; ?>

+

lang['MASS_EMAIL']; ?>

-

lang['Mass_email_explain']; ?>

+

lang['MASS_EMAIL_EXPLAIN']; ?>

-
+ +
- + - + - + - - +
lang['Compose']; ?>lang['COMPOSE']; ?>
lang['Recipients']; ?>lang['RECIPIENTS']; ?>
lang['Subject']; ?>lang['SUBJECT']; ?>
lang['Message']; ?> + lang['MESSAGE']; ?>
diff --git a/phpBB/includes/emailer.php b/phpBB/includes/emailer.php index 8deba01c4d..d08ca0f3a6 100755 --- a/phpBB/includes/emailer.php +++ b/phpBB/includes/emailer.php @@ -30,11 +30,13 @@ class emailer function emailer($use_queue = false) { + global $config; + $this->use_queue = $use_queue; if ($use_queue) { $this->queue = new Queue(); - $this->queue->init('emailer', 100); + $this->queue->init('emailer', $config['email_package_size']); } $this->reset(); } @@ -472,7 +474,7 @@ class Queue } //--TEMP - function queue_filled() + function is_queue_filled() { if (file_exists($this->cache_file)) { @@ -579,7 +581,7 @@ class Queue $sql = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . time() . "' WHERE config_name = 'last_queue_run'"; - $db->sql_query(); + $db->sql_query($sql); } function save() diff --git a/phpBB/install/schemas/mysql_basic.sql b/phpBB/install/schemas/mysql_basic.sql index e8c02f1f8d..59152ebd62 100644 --- a/phpBB/install/schemas/mysql_basic.sql +++ b/phpBB/install/schemas/mysql_basic.sql @@ -83,6 +83,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('display_last_edite INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_email_sig','Thanks, The Management'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_email','address@yourdomain.tld'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_contact','contact@yourdomain.tld'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('email_package_size','50'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_delivery','0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_host',''); INSERT INTO phpbb_config (config_name, config_value) VALUES ('smtp_port','25'); diff --git a/phpBB/language/en/email/admin_send_email.txt b/phpBB/language/en/email/admin_send_email.txt index 234f61df52..a0da5e28ba 100644 --- a/phpBB/language/en/email/admin_send_email.txt +++ b/phpBB/language/en/email/admin_send_email.txt @@ -2,7 +2,7 @@ Charset: iso-8859-1 The following is an email sent to you by an administrator of "{SITENAME}". If this message is spam, contains abusive or other comments you find offensive please contact the webmaster of the board at the following address: -{BOARD_EMAIL} +{CONTACT_EMAIL} Include this full email (particularly the headers). diff --git a/phpBB/language/en/lang_admin.php b/phpBB/language/en/lang_admin.php index be7a027c34..61e7185f36 100644 --- a/phpBB/language/en/lang_admin.php +++ b/phpBB/language/en/lang_admin.php @@ -95,7 +95,7 @@ $lang = array_merge($lang, array( 'log_index_activate' => 'Activated inactive users
%s users', 'log_index_delete' => 'Deleted inactive users
%s', 'LOG_INDEX_REMIND' => 'Sent reminder emails to inactive users
%s', - 'log_mass_email' => 'Sent mass email
%s', + 'LOG_MASS_EMAIL' => 'Sent mass email
%s', 'log_delete_word' => 'Deleted word censor', 'log_edit_word' => 'Edited word censor
%s', 'log_add_word' => 'Added word censor
%s', @@ -507,6 +507,8 @@ $lang = array_merge($lang, array( 'ENABLE_EMAIL_EXPLAIN' => 'If this is set to disabled no emails will be sent by the board at all.', 'BOARD_EMAIL_FORM' => 'Users send email via board', 'BOARD_EMAIL_FORM_EXPLAIN' => 'This function keeps email addresses completely private.', + 'EMAIL_PACKAGE_SIZE' => 'Email Package Size', + 'EMAIL_PACKAGE_SIZE_EXPLAIN' => 'This is the number of emails sent in one package.', 'ADMIN_EMAIL' => 'Return Email Address', 'ADMIN_EMAIL_EXPLAIN' => 'This will be used as the return address on all emails.', 'EMAIL_SIG' => 'Email Signature', @@ -839,11 +841,10 @@ $lang = array_merge($lang, array( 'WORD_REMOVED' => 'The selected word censor has been successfully removed', - 'Mass_email_explain' => 'Here you can email a message to either all of your users, or all users of a specific group. To do this, an email will be sent out to the administrative email address supplied, with a blind carbon copy sent to all recipients. If you are emailing a large group of people please be patient after submitting and do not stop the page halfway through. It is normal for a mass emailing to take a long time, you will be notified when the script has completed', - 'Compose' => 'Compose', - 'Recipients' => 'Recipients', - 'All_users' => 'All Users', - 'Email_successfull' => 'Your message has been sent', + 'MASS_EMAIL_EXPLAIN' => 'Here you can email a message to either all of your users, or all users of a specific group. To do this, an email will be sent out to the administrative email address supplied, with a blind carbon copy sent to all recipients. If you are emailing a large group of people please be patient after submitting and do not stop the page halfway through. It is normal for a mass emailing to take a long time, you will be notified when the script has completed', + 'COMPOSE' => 'Compose', + 'RECIPIENTS' => 'Recipients', + 'ALL_USERS' => 'All Users', 'RANKS_EXPLAIN' => 'Using this form you can add, edit, view and delete ranks. You can also create custom ranks which can be applied to a user via the user management facility',