[其它]郵件強制大五碼發送

與 phpBB 2.0.x 相關主題。

版主: 版主管理群

回覆文章
神川小羽
調皮の小羽
調皮の小羽
文章: 1461
註冊時間: 2004-05-01 05:55
來自: 謎樣之筱語
聯繫:

[其它]郵件強制大五碼發送

文章 神川小羽 »

:arrow: 下載點我::downloads

整理了幾次,大致上是這樣了,不過使用者必須知道這並不是郵件問題解決的唯一方式不論是用UTF-8送或BIG5發送都是可行的,使用者就自己衡量看看是用UTF-8還是要改成強制BIG5發送嚕,而當然強制轉換為BIG5也不見的是最好的方式

代碼: 選擇全部

############################################################## 
## 名稱: 郵件強制大五碼發送
## 作者: 神川小羽 < 不想貼信箱討厭垃圾信 > http://pbtw.net/
## 描述: 強制將 UTF8 化的 PHPBB 送出的郵件轉換為大五碼big5
## 版本: 1.0.2
## 
## 安裝難度:		簡單
## 安裝時間:		1 分鐘
##
## 需要編輯的檔案:	1
##	emailer.php
##	
## 附加的檔案:          0
##
############################################################## 
## 版本歷史:
##
##   2006-03-14 - 版本 1.0.0
##      - 測試在台灣雅虎信箱以及Google還有Outlook Express測試收信無亂碼
##
##   2006-03-15 - 版本 1.0.1
##      - 修正物件成員msg沒有轉換的bug
##
##   2006-03-15 - 版本 1.0.2
##      - 修正我沒有注意到的 charset 
##
############################################################## 
## 版權宣告:
##  沒有特別的宣告,只是簡單的應用而已。
##
##############################################################
## 注意事項:
## 1.在你嘗試修改前,建議您先行備份相關檔案以免不測。
## 2.你的主機必須安裝 mbstring 函式庫模組才能使用此修正。
## 3.你的郵件樣版必須是 utf-8 編碼且樣板中 Charset 必須是 utf-8
## 4.你的語系中 $lang['ENCODING'] 必須是 utf-8
##
############################################################## 
#
#---- [ 打開 ] ---------------------------
#

代碼: 選擇全部

includes/emailer.php
#
#---- [ 找到 ] ---------------------------
#

代碼: 選擇全部

class emailer
{
	var $msg, $subject, $extra_headers;
	var $addresses, $reply_to, $from;
	var $use_smtp;
#
#---- [ 之後加入 ] ---------------------------
#

代碼: 選擇全部

	//------------ 郵件修正1 開始 ----------------
	var $new_email_encode = 'big5';
	//------------ 郵件修正1 結束 ----------------
#
#---- [ 找到 ] ---------------------------
#

代碼: 選擇全部

		$this->extra_headers = (($this->reply_to != '') ? "Reply-to: $this->reply_to\n" : '') . (($this->from != '') ? "From: $this->from\n" : "From: " . $board_config['board_email'] . "\n") . "Return-Path: " . $board_config['board_email'] . "\nMessage-ID: <" . md5(uniqid(time())) . "@" . $board_config['server_name'] . ">\nMIME-Version: 1.0\nContent-type: text/plain; charset=" . $this->encoding . "\nContent-transfer-encoding: 8bit\nDate: " . date('r', time()) . "\nX-Priority: 3\nX-MSMail-Priority: Normal\nX-Mailer: PHP\nX-MimeOLE: Produced By phpBB2\n" . $this->extra_headers . (($cc != '') ? "Cc: $cc\n" : '')  . (($bcc != '') ? "Bcc: $bcc\n" : '');
#
#---- [ 取代 ] ---------------------------
#

代碼: 選擇全部

		//------------ 郵件修正2 開始 ----------------
		/** 修改 charset
		$this->extra_headers = (($this->reply_to != '') ? "Reply-to: $this->reply_to\n" : '') . (($this->from != '') ? "From: $this->from\n" : "From: " . $board_config['board_email'] . "\n") . "Return-Path: " . $board_config['board_email'] . "\nMessage-ID: <" . md5(uniqid(time())) . "@" . $board_config['server_name'] . ">\nMIME-Version: 1.0\nContent-type: text/plain; charset=" . $this->encoding . "\nContent-transfer-encoding: 8bit\nDate: " . date('r', time()) . "\nX-Priority: 3\nX-MSMail-Priority: Normal\nX-Mailer: PHP\nX-MimeOLE: Produced By phpBB2\n" . $this->extra_headers . (($cc != '') ? "Cc: $cc\n" : '')  . (($bcc != '') ? "Bcc: $bcc\n" : ''); 
		**/
		$this->extra_headers = (($this->reply_to != '') ? "Reply-to: $this->reply_to\n" : '') . (($this->from != '') ? "From: $this->from\n" : "From: " . $board_config['board_email'] . "\n") . "Return-Path: " . $board_config['board_email'] . "\nMessage-ID: <" . md5(uniqid(time())) . "@" . $board_config['server_name'] . ">\nMIME-Version: 1.0\nContent-type: text/plain; charset=" . $this->new_email_encode . "\nContent-transfer-encoding: 8bit\nDate: " . date('r', time()) . "\nX-Priority: 3\nX-MSMail-Priority: Normal\nX-Mailer: PHP\nX-MimeOLE: Produced By phpBB2\n" . $this->extra_headers . (($cc != '') ? "Cc: $cc\n" : '')  . (($bcc != '') ? "Bcc: $bcc\n" : '');
		//------------ 郵件修正2 結束 ----------------
#
#---- [ 找到 ] ---------------------------
#

代碼: 選擇全部

		// Send message ... removed $this->encode() from subject for time being
		if ( $this->use_smtp )
		{
			if ( !defined('SMTP_INCLUDED') ) 
			{
				include($phpbb_root_path . 'includes/smtp.' . $phpEx);
			}
#
#---- [ 之後加入 ] ---------------------------
#

代碼: 選擇全部

			//------------ 郵件修正3 開始 ----------------
			$this->subject = '=?'.$this->new_email_encode.'?B?' . base64_encode(mb_convert_encoding($this->subject, $this->new_email_encode, $lang['ENCODING'])).'?=';
			$this->msg = mb_convert_encoding($this->msg, $this->new_email_encode, $lang['ENCODING']);
			$this->extra_headers = mb_convert_encoding($this->extra_headers, $this->new_email_encode, $lang['ENCODING']);
			//------------ 郵件修正3 結束 ----------------
#
#---- [ 找到 ] ---------------------------
#

代碼: 選擇全部

		else
		{
			$empty_to_header = ($to == '') ? TRUE : FALSE;
			$to = ($to == '') ? (($board_config['sendmail_fix']) ? ' ' : 'Undisclosed-recipients:;') : $to;
#
#---- [ 之後加入 ] ---------------------------
#

代碼: 選擇全部

			//------------ 郵件修正4 開始 ----------------
			$this->subject = '=?'.$this->new_email_encode.'?B?' . base64_encode(mb_convert_encoding($this->subject, $this->new_email_encode, $lang['ENCODING'])).'?=';
			$this->msg = mb_convert_encoding($this->msg, $this->new_email_encode, $lang['ENCODING']);
			$this->extra_headers = mb_convert_encoding($this->extra_headers, $this->new_email_encode, $lang['ENCODING']);
			//------------ 郵件修正4 結束 ----------------
#
#---- [ 找到 ] ---------------------------
#

代碼: 選擇全部

	function attachFile($filename, $mimetype = "application/octet-stream", $szFromAddress, $szFilenameToDisplay)
	{
		global $lang;
#
#---- [ 之後加入 ] ---------------------------
#

代碼: 選擇全部

		//------------ 郵件修正5 開始 ----------------
		$lang['ENCODING'] = $this->new_email_encode;
		//------------ 郵件修正5 結束 ----------------
#
#---- [ 完成/存檔/上傳檔案 ] ---------------------------
#
#結束
-.-
回覆文章

回到「2.0」