function mail_invitation($emails, $content, $name) { global $INI; if (empty($emails)) { return; } $emails = preg_split('/[\\s,]+/', $emails, -1, PREG_SPLIT_NO_EMPTY); $subject = "您的好友[{$name}]邀请您注册{$INI['system']['sitename']}"; $vars = array('name' => $name, 'content' => $content); $message = render('mail_invite', $vars); $step = ceil(count($emails) / 20); for ($i = 0; $i < $step; $i++) { $offset = $i * 20; $tos = array_slice($emails, $offset, 20); mail_custom($tos, $subject, $message); } return true; }
require_once dirname(dirname(dirname(__FILE__))) . '/app.php'; need_manager(); if ($_POST) { $_POST['content'] = stripslashes($_POST['content']); $content = $_POST['content']; $emails = $_POST['emails']; $subject = $_POST['title']; $emails = preg_split('/[\\s,]+/', $emails, -1, PREG_SPLIT_NO_EMPTY); $emails_array = array(); foreach ($emails as $one) { if (Utility::ValidEmail($one)) { $emails_array[] = $one; } } $email_count = count($emails_array); $hostprefix = "http://{$_SERVER['HTTP_HOST']}/"; $content = str_ireplace('href="/', "href=\"{$hostprefix}", $content); if (!$email_count) { Session::Set('error', '发送邮件错误:缺少合法的收件人邮件地址'); } else { try { mail_custom($emails_array, $subject, $content); Session::Set('notice', "发送邮件成功,数量:{$email_count}"); Utility::Redirect(WEB_ROOT . '/manage/market/index.php'); } catch (Exception $e) { Session::Set('error', '发送邮件错误:' . $e->getMessage()); } } } include template('manage_market_email');