[教學][修正] 電子郵件通知

與 phpBB 2.0.x 相關主題。

版主: 版主管理群

回覆文章
Mowd
竹貓忠實會員
竹貓忠實會員
文章: 326
註冊時間: 2002-06-26 01:17
來自: 台北
聯繫:

[教學][修正] 電子郵件通知

文章 Mowd » 2005-05-27 12:30

管理員在寄電子郵件通知時,如果收件人達到一定人數將會出現:
Ran into problems sending Mail. Response: 552 Too many Recipients.
解決方法是讓郵件伺服器不要一次收到那麼多信,而是分段寄出,解決方法由竹貓會員C.K.提出,詳細方法如下:

打開admin/admin_mass_email.php 在122行

-----------找尋-----------

代碼: 選擇全部

		for ($i = 0; $i < count($bcc_list); $i++)
		{
			$emailer->bcc($bcc_list[$i]);
		}

		$email_headers = 'X-AntiAbuse: Board servername - ' . $board_config['server_name'] . "
";
		$email_headers .= 'X-AntiAbuse: User_id - ' . $userdata['user_id'] . "
";
		$email_headers .= 'X-AntiAbuse: Username - ' . $userdata['username'] . "
";
		$email_headers .= 'X-AntiAbuse: User IP - ' . decode_ip($user_ip) . "
";

		$emailer->use_template('admin_send_email');
		$emailer->email_address($board_config['board_email']);
		$emailer->set_subject($subject);
		$emailer->extra_headers($email_headers);

		$emailer->assign_vars(array(
			'SITENAME' => $board_config['sitename'], 
			'BOARD_EMAIL' => $board_config['board_email'], 
			'MESSAGE' => $message)
		);
		$emailer->send();
		$emailer->reset();
-----------取代成下面-----------

代碼: 選擇全部

		$I_Send = 1;
		$Z_Send = 250;//每次寄信的數量
		$A_Send = count($bcc_list);//寄信總量

		for ($i = 0; $i < count($bcc_list); $i++)
		{
			$Y_Send = $I_Send % $Z_Send;//判斷是否到達寄信數量
			$emailer->bcc($bcc_list[$i]);
			if ($Y_Send == 0 || $I_Send == $A_Send){//判斷是否到達寄信數量或者到達最後一位使用者

				$email_headers = 'X-AntiAbuse: Board servername - ' . $board_config['server_name'] . "
";
				$email_headers .= 'X-AntiAbuse: User_id - ' . $userdata['user_id'] . "
";
				$email_headers .= 'X-AntiAbuse: Username - ' . $userdata['username'] . "
";
				$email_headers .= 'X-AntiAbuse: User IP - ' . decode_ip($user_ip) . "
";
				
				$emailer->use_template('admin_send_email');
				$emailer->email_address($board_config['board_email']);
				$emailer->set_subject($subject);
				$emailer->extra_headers($email_headers);

				$emailer->assign_vars(array(
					'SITENAME' => $board_config['sitename'], 
					'BOARD_EMAIL' => $board_config['board_email'], 
\n					'MESSAGE' => $message)
					);
				$emailer->send();
				$emailer->reset();

			}
			$I_Send = $I_Send+1;
		}
只寄帳號有啟用的人其他沒啟用的不發信

打開admin/admin_mass_email.php 大概在74行

-----------找尋-----------

代碼: 選擇全部

$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;
-----------取代成下面-----------

代碼: 選擇全部

$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 AND u.user_active = 1" : "SELECT user_email FROM " . USERS_TABLE . " WHERE user_active = 1";

回覆文章

回到「2.0」