Subversion Repositories php-qbpwcf

Rev

Rev 30 | Rev 48 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php

/*

        QBPWCF, Quick Build PHP website Component base on Fedora Linux.
    Copyright (C) 2014~2025 Min-Jhin,Chen

    This file is part of QBPWCF.

    QBPWCF is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    QBPWCF is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with QBPWCF.  If not, see <http://www.gnu.org/licenses/>.

*/
namespace qbpwcf;

/*
類別說明:
跟E-Mail應用有關的類別.
備註:
無.
*/
class mail{

        /*
        #函式說明:
        #當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
        #回傳結果:
        #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
        #$reuslt["error"],執行不正常結束的錯訊息陣列.
        #$result["function"],當前執行的函式名稱.
        #必填參數:
        #$method,物件,為物件實體或類別名稱,會自動置入該參數.
        #$arguments,陣列,為呼叫方法時所用的參數.
        #可省略參數:
        #無.
        #參考資料:
        #__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
        #備註:
        #無.
        */
        public function __call($method,$arguments){
                
                #取得當前執行的函式
                $result["function"]=__FUNCTION__;
                
                #設置執行不正常
                $result["status"]="false";
                
                #設置執行錯誤
                $result["error"][]=__NAMESPACE__ ."/".$method."() 不存在!";
                
                #設置所丟入的參數
                $result["error"][]=$arguments;
                
                #回傳結果
                return $result;
                
                }#function __call end
                
        /*
        #函式說明:
        #當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
        #回傳結果:
        #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
        #$reuslt["error"],執行不正常結束的錯訊息陣列.
        #$result["function"],當前執行的函式名稱.
        #必填參數:
        #$method,物件,為物件實體或類別名稱,會自動置入該參數.
        #$arguments,陣列,為呼叫方法時所用的參數.
        #可省略參數:
        #無.
        #參考資料:
        #__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
        #備註:
        #無.
        */
        public static function __callStatic($method,$arguments){
                
                #取得當前執行的函式
                $result["function"]=__FUNCTION__;
                
                #設置執行不正常
                $result["status"]="false";
                
                #設置執行錯誤
                $result["error"][]="欲呼叫的". __NAMESPACE__ ."/".$method."() 不存在!";
                
                #設置所丟入的參數
                $result["error"][]=$arguments;
                
                #回傳結果
                return $result;
                
                }#function __callStatic end
        
        /*
        #函式說明:
        #登入 imap 信箱
        #回傳結果:
        #$result["status"],寄信的情況,若爲"true",則十之八九沒有問題.
        #$result["error"],錯誤訊息陣列
        #$result["function"],當前執行的函數
        #$result["content"],執行imap_open()的回傳內容
        #必填參數:
        $conf["username"]="";#使用者帳戶
        $conf["password"]="";#使用者密碼
        #可省略參數:
        #$conf["mailServerPositionAndPort"]="";#信箱伺服器的網址與連接口,若省略則採用預設的gmail信箱
        #參考資料:
        #http://www.php.net/manual/en/function.imap-open.php
        #http://davidwalsh.name/gmail-php-imap
        #https://support.google.com/mail/troubleshooter/1668960?rd=1#ts=1665018,1665144
        #備註:
        #無.
        */
        public static function imapLogin(&$conf){

                #初始化要回傳的結果
                $result=array();

                #儲存當前執行的函數
                $result["function"]=__FUNCTION__;

                #如果 $conf 不為陣列
                if(gettype($conf)!="array"){
                        
                        #設置執行失敗
                        $result["status"]="false";
                        
                        #設置執行錯誤訊息
                        $result["error"][]="\$conf變數須為陣列形態";

                        #如果傳入的參數為 null
                        if($conf==null){
                                
                                #設置執行錯誤訊息
                                $result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
                                
                                }#if end

                        #回傳結果
                        return $result;
        
                        }#if end
        
                #檢查參數
                #函式說明:
                #檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                #$reuslt["error"],執行不正常結束的錯訊息陣列.
                #$result["function"],當前執行的函式名稱.
                #$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
                #$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
                #$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
                #$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
                #$result["argu"],字串陣列,目前輸入的參數名稱陣列.
                #$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
                #$result["notNeedVar"],字串陣列,多餘的參數名稱.
                #必填寫的參數:
                #$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
                $conf["variableCheck::checkArguments"]["varInput"]=&$conf;
                #$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("username","password");
                #$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); 
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
                #$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
                $conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
                #可以省略的參數:
                #$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
                #$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
                #$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["skipableVariableName"]=array("mailServerPositionAndPort");
                #$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
                $conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
                #$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
                $conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("imap.gmail.com:993");
                #$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
                #$conf["arrayCountEqualCheck"][]=array();
                #參考資料來源:
                #array_keys=>http://php.net/manual/en/function.array-keys.php
                $checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
                unset($conf["variableCheck::checkArguments"]);
        
                #如果檢查失敗
                if($checkArguments["status"]=="false"){
                        
                        #設置錯誤識別
                        $result["status"]="false";
                        
                        #設置錯誤訊息
                        $result["error"]=$checkArguments;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
        
                #如果檢查不通過
                if($checkArguments["passed"]=="false"){
                        
                        #設置錯誤識別
                        $result["status"]="false";
                        
                        #設置錯誤訊息
                        $result["error"]=$checkArguments;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end

                #To connect to an SSL IMAP or POP3 server, add /ssl after the protocol
                #specification:
                $mbox = \imap_open("{".$conf["mailServerPositionAndPort"]."/imap/ssl}INBOX",$conf["username"],$conf["password"]) or die("Cannot connect to mail server:".imap_last_error());

                #如果 imap_open() 執行失敗
                if($mbox["status"]==false){
                        
                        #設置執行不正常
                        $result["status"]="false";
                        
                        #設置錯誤訊息
                        $result["error"]=\imap_last_error();
                        
                        }#if end

                #儲存執行 imap_open() 後的 resource
                $result["content"]=$mbox;

                #設置執行正常
                $result["status"]="true";

                #回傳連結訊息
                return $result;

                }#function imapLogin end

        /*
        #函式說明:
        #登出信箱
        #$result["status"],寄信的情況,若爲"true",則十之八九沒有問題.
        #$result["error"],錯誤訊息陣列
        #$result["function"],當前執行的函數
        #必填參數:
        #$conf["mailConnection"],字串,連結到mailServer的資訊
        $conf["mailConnection"]="";
        #可省略參數:
        #無.
        #參考資料:
        #http://www.php.net/manual/en/function.imap-open.php
        #http://davidwalsh.name/gmail-php-imap
        #備註:
        #無.
        */
        public static function imapLogout(&$conf){

                #初始化要回傳的結果
                $result=array();

                #儲存當前執行的函數
                $result["function"]=__FUNCTION__;

                #如果 $conf 不為陣列
                if(gettype($conf)!="array"){
                        
                        #設置執行失敗
                        $result["status"]="false";
                        
                        #設置執行錯誤訊息
                        $result["error"][]="\$conf變數須為陣列形態";

                        #如果傳入的參數為 null
                        if($conf==null){
                                
                                #設置執行錯誤訊息
                                $result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
                                
                                }#if end

                        #回傳結果
                        return $result;
        
                        }#if end
        
                #檢查參數
                #函式說明:
                #檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                #$reuslt["error"],執行不正常結束的錯訊息陣列.
                #$result["function"],當前執行的函式名稱.
                #$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
                #$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
                #$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
                #$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
                #$result["argu"],字串陣列,目前輸入的參數名稱陣列.
                #$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
                #$result["notNeedVar"],字串陣列,多餘的參數名稱.
                #必填寫的參數:
                #$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
                $conf["variableCheck::checkArguments"]["varInput"]=&$conf;
                #$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("mailConnection");
                #$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); 
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("resource");
                #$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
                $conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
                #可以省略的參數:
                #$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
                $conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
                #$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
                #$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("mailServerPositionAndPort");
                #$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
                #$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
                #$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
                #$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("imap.gmail.com:993");
                #$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
                #$conf["arrayCountEqualCheck"][]=array();
                #參考資料來源:
                #array_keys=>http://php.net/manual/en/function.array-keys.php
                $checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
                unset($conf["variableCheck::checkArguments"]);
        
                #如果檢查失敗
                if($checkArguments["status"]=="false"){
                        
                        #設置錯誤識別
                        $result["status"]="false";
                        
                        #設置錯誤訊息
                        $result["error"]=$checkArguments;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
        
                #如果檢查不通過
                if($checkArguments["passed"]=="false"){
                        
                        #設置錯誤識別
                        $result["status"]="false";
                        
                        #設置錯誤訊息
                        $result["error"]=$checkArguments;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end

                #如果中斷與mailServer的連線失敗
                if(\imap_close($conf["mailConnection"])==false){
                        
                        #設置執行不正常
                        $result["status"]="false";
                        
                        #設置錯誤訊息
                        $result["error"][]="中斷與 imap Server 的連線失敗";
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
                        
                #設置執行正常
                $result["status"]="true";
                
                #回傳結果
                return $result;

                }#function imapLogout end

        /*
        #函式說明:
        #用imap協定寄信
        #回傳結果:
        #$result["status"],寄信的情況,"true"爲成功,"false"爲失敗.
        #$result["error"],錯誤訊息陣列
        #$result["function"],當前執行的函數
        #必填參數:
        $conf["username"]="";#郵件服務的登入帳號
        $conf["password"]="";#郵件服務的登入密碼
        $conf["receiver"]="";#收件着
        $conf["subject"]="";#信件主旨
        $conf["body"]="";#本文
        #可省略參數:
        #$conf["mailServerPositionAndPort"]="";#郵件伺服器的網址與連接口,若省略則採用預設的gmail信箱
        #$conf["headerInfo"]="";#表頭訊息,預設爲"From:".$conf["username"]."\r\n"."Reply-To:".$conf["receiver"]."\r\n";
        #$conf["cc"]="";#信件的副本要寄給誰
        #$conf["bcc"]="";#信件的密件副本要寄給誰,預設爲$conf["username"],以作爲備份。
        #參考資料:
        #http://www.php.net/manual/en/function.imap-mail.php
        #http://www.php.net/manual/en/function.imap-errors.php
        #http://www.php.net/manual/en/function.imap-alerts.php
        #http://www.php.net/manual/en/function.imap-last-error.php
        #http://wiki.dreamhost.com/PHP_IMAP#Verify_PHP_INI_Settings
        #備註:
        #需要php-imap套件
        #無法寄送成功?
        */              
        public static function mailTo(&$conf){

                #初始化要回傳的結果
                $result=array();

                #儲存當前執行的函數
                $result["function"]=__FUNCTION__;

                #如果 $conf 不為陣列
                if(gettype($conf)!="array"){
                        
                        #設置執行失敗
                        $result["status"]="false";
                        
                        #設置執行錯誤訊息
                        $result["error"][]="\$conf變數須為陣列形態";

                        #如果傳入的參數為 null
                        if($conf==null){
                                
                                #設置執行錯誤訊息
                                $result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
                                
                                }#if end

                        #回傳結果
                        return $result;
        
                        }#if end
        
                #檢查參數
                #函式說明:
                #檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                #$reuslt["error"],執行不正常結束的錯訊息陣列.
                #$result["function"],當前執行的函式名稱.
                #$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
                #$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
                #$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
                #$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
                #$result["argu"],字串陣列,目前輸入的參數名稱陣列.
                #$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
                #$result["notNeedVar"],字串陣列,多餘的參數名稱.
                #必填寫的參數:
                #$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
                $conf["variableCheck::checkArguments"]["varInput"]=&$conf;
                #$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("username","password","receiver","subject","body");
                #$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); 
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","string","string","string");
                #$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
                $conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
                #可以省略的參數:
                #$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
                #$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
                #$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["skipableVariableName"]=array("mailServerPositionAndPort","headerInfo","cc","bcc");
                #$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
                $conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string","string");
                #$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
                $conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,null,null,"\$conf[\"username\"]");
                #$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
                #$conf["arrayCountEqualCheck"][]=array();
                #參考資料來源:
                #array_keys=>http://php.net/manual/en/function.array-keys.php
                $checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
                unset($conf["variableCheck::checkArguments"]);
        
                #如果檢查失敗
                if($checkArguments["status"]=="false"){
                        
                        #設置錯誤識別
                        $result["status"]="false";
                        
                        #設置錯誤訊息
                        $result["error"]=$checkArguments;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
        
                #如果檢查不通過
                if($checkArguments["passed"]=="false"){
                        
                        #設置錯誤識別
                        $result["status"]="false";
                        
                        #設置錯誤訊息
                        $result["error"]=$checkArguments;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end

                #函式說明:
                #登入信箱
                #回傳結果:
                #$result,連結mail的訊息。
                #必填參數:
                $conf["mail"]["login"]["username"]=$conf["username"];#使用者帳戶
                $conf["mail"]["login"]["password"]=$conf["password"];#使用者密碼
                #可省略參數:

                #若 $conf["mail"]["login"]["mailServerPositionAndPort"] 沒有設置,則預設爲gmail信箱
                if(!isset($conf["mail"]["login"]["mailServerPositionAndPort"])){
                        
                        $conf["mail"]["login"]["mailServerPositionAndPort"]="imap.gmail.com:993";

                        }#if end

                #反之有設定,則採用指定值
                else{

                        $conf["mail"]["login"]["mailServerPositionAndPort"]=$conf["mailServerPositionAndPort"];

                        }#else end

                #$conf["mailServerPositionAndPort"]="";#信箱伺服器的網址與連接口,若省略則採用預設的gmail信箱
                #參考資料來源:
                #http://www.php.net/manual/en/function.imap-open.php
                #http://davidwalsh.name/gmail-php-imap
                $mailConnection=mail::imapLogin($conf["mail"]["login"]);
                unset($conf["mail"]["login"]);

                #如果登入imap伺服器失敗
                if($mailConnection["status"]=="false"){
                        
                        #設置錯誤訊息
                        $result["error"]=$mailConnection;
                        
                        #設置執行失敗
                        $result["status"]="false";
                        
                        #回傳結果
                        return $result;
                        
                        }#if end

                #如果 $conf["headerInfo"] 沒有指定
                if(!isset($conf["headerInfo"])){

                        $conf["headerInfo"]="From:".$conf["username"]."\r\n"."Reply-To:".$conf["receiver"]."\r\n";

                        }#if end

                #如果 $conf["cc"] 沒有設定
                if(!isset($conf["cc"])){

                        #則設爲null
                        $conf["cc"]=null;

                        }#if end

                #用imap寄出信件
                $result["mailToStatus"]=\imap_mail($conf["receiver"],imap_utf8($conf["subject"]),imap_utf8($conf["body"]),imap_utf8($conf["headerInfo"]),imap_utf8($conf["cc"]),imap_utf8($conf["bcc"]),imap_utf8($conf["username"]));
                        
                #取得使用imap服務與到的警示訊息
                $result["imapAlerts"]=\imap_alerts();

                #取得使用imap服務與到的錯誤訊息
                $result["imapErrors"]=\imap_errors();

                #取得使用imap服務與到的最新錯誤訊息
                $result["imapLastErrors"]=\imap_last_error();

                #函式說明:
                #登出信箱
                #必填參數
                $conf["mail"]["logout"]["mailConnection"]=$mailConnection["content"];#連結到mailServer的資訊
                #參考資料來源:
                #http:#www.php.net/manual/en/function.imap-open.php
                #http:#davidwalsh.name/gmail-php-imap
                $imapLogout=mail::imapLogout($conf["mail"]["logout"]);
                unset($conf["mail"]["logout"]);

                #如果登出imap伺服器失敗
                if($imapLogout["status"]=="false"){
                        
                        #設置執行失敗
                        $result["status"]="false";
                        
                        #設置錯誤訊息
                        $result["error"]=$imapLogout;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end

                #設置執行正常
                $result["status"]="true";

                #回傳寄信的結果
                return $result;

                }#function mailTo end

        /*
        #函式說明:
        #使用 curl 來透過SMTP伺服器寄信
        #回傳結果:
        #$result["status"],寄信的情況,若爲"true",則十之八九沒有問題.
        #$result["error"],錯誤訊息陣列
        #$result["function"],當前執行的函數
        #$result["warning"],警示訊息,一些不會導致失敗但不能說是完美的問題.
        #$result["cmd"],寄信的指令.
        #$result["detailCmd"],較詳細的寄信指令.
        #必填參數:
        #$conf["username"],字串,用來登入郵件伺服器的帳號
        $conf["username"]="";
        #$conf["password"],字串,用來登入郵件伺服器的密碼
        $conf["password"]="";
        #$conf["receiverMail"],陣列,收件人的信箱
        $conf["receiverMail"]=array("");
        #$conf["subject"],字串,郵件的主題
        $conf["subject"]="";
        #$conf["plainBody"],字串,郵件本文的純文字內容.
        $conf["plainBody"]="";
        #$conf["htmlBody"]="";,字串,郵件本文的html內容,多媒體盡量不要用base64的方式來嵌入,因為大部分的郵件服務(Gmail)都不支援,如果是在單機上的郵件軟體就可能有支援,例如:Evolution.
        $conf["htmlBody"]="";
        #$conf["fileArgu"],字串,php內建變數「__FILE__」的內容.
        $conf["fileArgu"]=__FILE__;
        #可省略參數:
        #$conf["mailServer"],字串,要使用的SMTP郵件伺服器網址與連接口,預設爲 smtps://smtp.gmail.com:465
        #$conf["mailServer"]="";
        #$conf["mailerMailDisplay"],字串,要顯示的寄件人信箱,預設爲 $conf["username"]
        #$conf["mailerMailDisplay"]="";
        #$conf["mailerNameDisplay"],字串,要顯示的寄件人姓名,預設爲 $conf["username"]
        #$conf["mailerNameDisplay"]="";
        #$conf["receiverMailDisplay"],陣列,要顯示的收件人信箱,預設爲 $conf["receiverMail"] 對應的元素.
        #$conf["receiverMailDisplay"]="";#
        #$conf["receiverNameDisplay"],陣列,要顯示的收件人姓名,預設爲 $conf["receiverMail"] 對應的元素.
        #$conf["receiverNameDisplay"]="";
        #$conf["attachment"],陣列,每個要寄送的附件路徑與檔案名稱
        #$conf["attachment"]=array();
        #$conf["attachmentName"],陣列,每個要寄送的附件顯示名稱,預設為$conf["attachment"]中的實際檔案名稱.
        #$conf["attachmentName"]=array();
        #$conf["attachmentMimeType"],陣列,每個附件的 mimeType,預設為"application/*".
        #$conf["attachmentMimeType"]array();
        #$conf["levelForCheckSSL"],"字串",預設為"force",代表ssl一定要符合規範,"loose"代表先嘗試ssl要符合規範,若不符合則第2次就允許不符合規範的ssl,"none"代表直接允許不符合規範的ssl.
        #$conf["levelForCheckSSL"]="";
        #範例語句:
        #curl --url smtps://smtp.gmail.com:465 -u username@gmail.com:userPassword --mail-from username@gmail.com --mail-rcpt receiver@mail.com --upload-file mail.txt -v
        #範例信件內容:
        #From: "userName" <username@gmail.com>
        #To: "receiverName" <userPassword@yahoo.com.tw>
        #Subject: This is a test
        #本文~
        #參考資料:
        #用curl來寄信=>http://stackoverflow.com/questions/14722556/using-curl-to-send-email
        #降低安全性標準讓curl可以使用=>https://www.google.com/settings/security/lesssecureapps
        #信件內容header的設定=>http://jjdai.zhupiter.com/2010/10/php-%E5%A6%82%E4%BD%95%E5%82%B3%E9%80%81%E4%B8%80%E5%B0%81-mime-html-%E6%A0%BC%E5%BC%8F%E7%9A%84-email-%E4%BF%A1%E4%BB%B6/
        #檔案每列不得超超過70個字元=>http://php.net/manual/en/function.mail.php
        #寄信給多人=>https://github.com/curl/curl/issues/784
        #備註:
        #無.
        */
        public static function curlSmtp(&$conf){

                #初始化要回傳的結果
                $result=array();

                #儲存當前執行的函數
                $result["function"]=__FUNCTION__;

                #如果 $conf 不為陣列
                if(gettype($conf)!="array"){
                        
                        #設置執行失敗
                        $result["status"]="false";
                        
                        #設置執行錯誤訊息
                        $result["error"][]="\$conf變數須為陣列形態";

                        #如果傳入的參數為 null
                        if($conf==null){
                                
                                #設置執行錯誤訊息
                                $result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
                                
                                }#if end

                        #回傳結果
                        return $result;
        
                        }#if end
        
                #檢查參數
                #函式說明:
                #檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                #$reuslt["error"],執行不正常結束的錯訊息陣列.
                #$result["function"],當前執行的函式名稱.
                #$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
                #$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
                #$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
                #$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
                #$result["argu"],字串陣列,目前輸入的參數名稱陣列.
                #$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
                #$result["notNeedVar"],字串陣列,多餘的參數名稱.
                #必填寫的參數:
                #$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
                $conf["variableCheck::checkArguments"]["varInput"]=&$conf;
                #$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("username","password","receiverMail","subject","plainBody","htmlBody","fileArgu");
                #$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); 
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","array","string","string","string","string");
                #$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
                $conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
                #可以省略的參數:
                #$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
                #$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
                #$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["skipableVariableName"]=array("attachment","attachmentName","attachmentMimeType","mailServer","mailerMailDisplay","mailerNameDisplay","receiverMailDisplay","receiverNameDisplay","levelForCheckSSL");
                #$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
                $conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array","array","array","string","string","string","string","string","string");
                #$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
                $conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,null,null,"smtps://smtp.gmail.com:465","\$conf[\"username\"]","\$conf[\"username\"]","\$conf[\"receiverMail\"]","\$conf[\"receiverMail\"]","force");
                #$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
                $conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("receiverMail","receiverMailDisplay","receiverNameDisplay");
                #參考資料來源:
                #array_keys=>http://php.net/manual/en/function.array-keys.php
                $checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
                unset($conf["variableCheck::checkArguments"]);
        
                #如果檢查失敗
                if($checkArguments["status"]=="false"){
                        
                        #設置錯誤識別
                        $result["status"]="false";
                        
                        #設置錯誤訊息
                        $result["error"]=$checkArguments;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
        
                #如果檢查不通過
                if($checkArguments["passed"]=="false"){
                        
                        #設置錯誤識別
                        $result["status"]="false";
                        
                        #設置錯誤訊息
                        $result["error"]=$checkArguments;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
        
                #檢查 curlSmtp 資料夾是否存在
                #函式說明:檢查多個檔案是否存在
                #回傳的結果:
                #$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
                #$result["error"],錯誤訊息陣列.
                #$resutl["function"],當前執行的涵式名稱.
                #$result["allExist"],所有檔案皆存在的識別,"true"代表皆存在,"false"代表沒有全部都存在.
                #$result["varName"][$i],爲第$i個資料夾或檔案的名稱。
                #$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
                #必填參數:
                $conf["fileAccess::checkMultiFileExist"]["fileArray"]=array(".curlSmtp");#要檢查書否存在的檔案有哪些,須爲一維陣列數值。
                $conf["fileAccess::checkMultiFileExist"]["fileArgu"]=$conf["fileArgu"];
                #參考資料來源:
                #http://php.net/manual/en/function.file-exists.php
                #http://php.net/manual/en/control-structures.foreach.php
                $checkMutiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
                unset($conf["fileAccess::checkMultiFileExist"]);
                
                #如果檢查檔案失敗
                if($checkMutiFileExist["status"]=="false"){
                        
                        #設置錯誤識別
                        $result["status"]="false";
                        
                        #設置錯誤訊息
                        $result["error"]=$checkMutiFileExist;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end

                #如果該資料夾不存在
                if($checkMutiFileExist["varExist"][0]=="false"){

                        #則建立該資料夾
                        #函式說明:
                        #建立資料夾,若要建立的資料夾所屬路徑不存在,則會自動嘗試建立,建立後的資料夾也可指定權限.
                        #回傳結果:
                        #$result["status"],"true"爲建立成功,"false"爲建立失敗.
                        #$result["error"],錯誤訊息陣列
                        #必填參數:
                        $conf["fileAccess::createFolderAfterCheck"]["dirPositionAndName"]=".curlSmtp";#新建的位置與名稱
                        $conf["fileAccess::createFolderAfterCheck"]["fileArgu"]=$conf["fileArgu"];
                        #可省略參數:
                        #$conf["fileAccess::createFolderAfterCheck"]["dirPermission"]="";#新建資料夾的權限設定,預設爲0770,亦即擁有者,同群組者可以讀,寫,存取,其他人僅能存取.
                        $createFolderAfterCheck=fileAccess::createFolderAfterCheck($conf["fileAccess::createFolderAfterCheck"]);
                        unset($conf["fileAccess::createFolderAfterCheck"]);
                        
                        #如果 建立資料夾失敗
                        if($createFolderAfterCheck["status"]=="false"){

                                #設置錯誤識別
                                $result["status"]="false";

                                #設置錯誤訊息
                                $result["errot"]=$createFolderAfterCheck;

                                #回傳結果
                                return $result;

                                }#if end

                        }#if end
                
                #取得 $systemTime     
                $systemTime=time::getMicrotime();

                #要傳送的信件資訊
                $mailFileHeader="From: ".$conf["mailerNameDisplay"]." <".$conf["mailerMailDisplay"].">\r\n";
                
                #第一個人主要收件人
                $mailFileHeader=$mailFileHeader."To: ".$conf["receiverNameDisplay"][0]." "."<".$conf["receiverMailDisplay"][0].">\r\n";                 
                
                #如果有其餘收件人
                if(count($conf["receiverNameDisplay"])>1){
                        
                        #副本寄送處的資訊開始
                        $mailFileHeader=$mailFileHeader."Cc: ";
                        
                        }#if end
                
                #針對其餘收件人的地址
                for($i=1;$i<count($conf["receiverNameDisplay"]);$i++){
                        
                        #如果不是最後一筆
                        if($i!=count($conf["receiverNameDisplay"])-1){
                                
                                $mailFileHeader=$mailFileHeader.$conf["receiverNameDisplay"][$i]." <".$conf["receiverMailDisplay"][$i].">,";
                                
                                }#if end
                        
                        #反之是最後一筆
                        else{
                                
                                $mailFileHeader=$mailFileHeader.$conf["receiverNameDisplay"][$i]." <".$conf["receiverMailDisplay"][$i].">\r\n";
                                
                                }#else end                              
                        
                        }#for end
                
                $mailFileHeader=$mailFileHeader."Subject: ".$conf["subject"]."\r\n";
        
                #初始化信件本文
                $mailFileContent="";
                        
                #初始化 boundary
                $boundary="001a11c30ce8aec3480533bfa9a9";
                
                #初始化 boundary start
                $boundaryS="--".$boundary;
                
                #初始化 boundary end 
                $boundaryE=$boundaryS."--";
                                        
                #設置信件本文(純文字與html兩種)                             
                $mailFileContent=$mailFileContent."Content-Type: multipart/alternative; boundary=\"".$boundary."\"\r\n";
                $mailFileContent=$mailFileContent."\r\n";
                $mailFileContent=$mailFileContent.$boundaryS."\r\n";
                $mailFileContent=$mailFileContent."Content-Type: text/plain; charset=UTF-8\r\n";
                $mailFileContent=$mailFileContent."\r\n";
                $mailFileContent=$mailFileContent.$conf["plainBody"]."\r\n";
                $mailFileContent=$mailFileContent."\r\n";
                $mailFileContent=$mailFileContent.$boundaryS."\r\n";
                $mailFileContent=$mailFileContent."Content-Type: text/html; charset=UTF-8\r\n";
                $mailFileContent=$mailFileContent."\r\n";
                $mailFileContent=$mailFileContent.$conf["htmlBody"]."\r\n";
                $mailFileContent=$mailFileContent.$boundaryE."\r\n";                    
                
                #依據規定,每列不得大於70的字元
                $mailFileContent==wordwrap($mailFileContent,70,"\r\n",true);
                
                #如果有設定要上傳附件
                if(isset($conf["attachment"])){
                                        
                        #依據每個附件
                        for($i=0;$i<count($conf["attachment"]);$i++){
                                
                                #初始化寄送附件的語法
                                $attachment="";
                                
                                #確認目標檔案是否存在
                                #函式說明:檢查多個檔案是否存在
                                #回傳的結果:
                                #$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
                                #$result["error"],錯誤訊息陣列.
                                #$resutl["function"],當前執行的涵式名稱.
                                #$result["allExist"],所有檔案皆存在的識別,"true"代表皆存在,"false"代表沒有全部都存在.
                                #$result["varName"][$i],爲第$i個資料夾或檔案的名稱。
                                #$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
                                #必填參數:
                                $conf["fileAccess::checkMultiFileExist"]["fileArgu"]=$conf["fileArgu"];
                                $conf["fileAccess::checkMultiFileExist"]["fileArray"]=array($conf["attachment"][$i]);#要檢查書否存在的檔案有哪些,須爲一維陣列數值。
                                #參考資料來源:
                                #http://php.net/manual/en/function.file-exists.php
                                #http://php.net/manual/en/control-structures.foreach.php
                                $checkMutiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
                                unset($conf["fileAccess::checkMultiFileExist"]);
                                        
                                #如果檢查失敗
                                if($checkMutiFileExist["status"]=="false"){
                                        
                                        #設置錯誤識別
                                        $result["status"]="false";

                                        #設置錯誤資訊
                                        $result["error"]=$checkMutiFileExist;

                                        #回傳結果
                                        return $result;
                                        
                                        }#if end
                                        
                                #如果檔案不存在
                                if($checkMutiFileExist["varExist"][0]=="false"){
                                        
                                        #設置錯誤識別
                                        $result["status"]="false";

                                        #設置錯誤資訊
                                        $result["error"]=$checkMutiFileExist;

                                        #回傳結果
                                        return $result;
                                        
                                        }#if end
                                        
                                #如果是第一個附件
                                if($i==0){
                                        
                                        #在前面加上 multipart/mixed 的 boundary
                                        $mailFileContent="Content-Type: multipart/mixed; boundary=".$boundary."\r\n\r\n".$mailFileContent;
                                        
                                        }#if end
                                        
                                #如果 $conf["attachmentName"] 不存在
                                if(!isset($conf["attachmentName"])){
                                        
                                        #涵是說明:
                                        #取得檔案路徑字串的路徑與檔案的名稱與檔案副檔名
                                        #回傳的結果:
                                        #$result["status"],執行是否正常,"true"正常,"false"代表不正常.
                                        #$result["error"],錯誤訊息.
                                        #$result["function"],當前執行的函式名稱.
                                        #$result["filePath"],路徑字串.
                                        #$result["fileName"],檔案名稱字串.
                                        #$result["fileExtention"],檔案的副檔名.
                                        #$result["fullFileName"],含副檔名的檔案名稱.
                                        #$result["fullFilePathAndName"],完整的檔案路徑(含副檔名).
                                        #必填參數:
                                        #$conf["fileAddressAndName"],字串,檔案名稱與其路徑.
                                        $conf["fileAccess::getFileAddressAndNameAndFileExtention"]["fileAddressAndName"]=$conf["attachment"][$i];
                                        #可省略的參數:
                                        #無.
                                        $getFileAddressAndNameAndFileExtention=fileAccess::getFileAddressAndNameAndFileExtention($conf["fileAccess::getFileAddressAndNameAndFileExtention"]);
                                        unset($conf["fileAccess::getFileAddressAndNameAndFileExtention"]);
                                                        
                                        #如果解析檔案資訊失敗         
                                        if($getFileAddressAndNameAndFileExtention["status"]=="false"){
                                                
                                                #設置錯誤識別
                                                $result["status"]="false";

                                                #設置錯誤資訊
                                                $result["error"]=$getFileAddressAndNameAndFileExtention;

                                                #回傳結果
                                                return $result;
                                                
                                                }#if end                        
                                                                        
                                        #設定附件名稱
                                        $conf["attachmentName"][$i]=$getFileAddressAndNameAndFileExtention["fullFileName"];
                                        
                                        }#if end
                                        
                                #反之如果 $conf["attachmentName"][$i] 不存在
                                else if(!isset($conf["attachmentName"][$i])){
                                        
                                        #涵是說明:
                                        #取得檔案路徑字串的路徑與檔案的名稱與檔案副檔名
                                        #回傳的結果:
                                        #$result["status"],執行是否正常,"true"正常,"false"代表不正常.
                                        #$result["error"],錯誤訊息.
                                        #$result["function"],當前執行的函式名稱.
                                        #$result["filePath"],路徑字串.
                                        #$result["fileName"],檔案名稱字串.
                                        #$result["fileExtention"],檔案的副檔名.
                                        #$result["fullFileName"],含副檔名的檔案名稱.
                                        #$result["fullFilePathAndName"],完整的檔案路徑(含副檔名).
                                        #必填參數:
                                        #$conf["fileAddressAndName"],字串,檔案名稱與其路徑.
                                        $conf["fileAccess::getFileAddressAndNameAndFileExtention"]["fileAddressAndName"]=$conf["attachment"][$i];
                                        #可省略的參數:
                                        #無.
                                        $getFileAddressAndNameAndFileExtention=fileAccess::getFileAddressAndNameAndFileExtention($conf["fileAccess::getFileAddressAndNameAndFileExtention"]);
                                        unset($conf["fileAccess::getFileAddressAndNameAndFileExtention"]);
                                                        
                                        #如果解析檔案資訊失敗         
                                        if($getFileAddressAndNameAndFileExtention["status"]=="false"){
                                                
                                                #設置錯誤識別
                                                $result["status"]="false";

                                                #設置錯誤資訊
                                                $result["error"]=$getFileAddressAndNameAndFileExtention;

                                                #回傳結果
                                                return $result;
                                                
                                                }#if end                        
                                                                        
                                        #設定附件名稱
                                        $conf["attachmentName"][$i]=$getFileAddressAndNameAndFileExtention["fullFileName"];
                                        
                                        }#if end
                                        
                                #如果 $conf["attachmentMimeType"] 不存在
                                if(!isset($conf["attachmentMimeType"])){
                                        
                                        #設定檔案類型
                                        $conf["attachmentMimeType"][$i]="application/*";
                                                                                                                
                                        }#if end        
                                        
                                #反之如果 $conf["attachmentMimeType"][$i] 不存在 
                                if(!isset($conf["attachmentMimeType"][$i])){
                                        
                                        $conf["attachmentMimeType"][$i]="application/*";
                                        
                                        }#if end
                                
                                #加上寄送附件的語法
                                $attachment=$attachment.$boundaryS."\r\n";
                                $attachment=$attachment."Content-Type: ".$conf["attachmentMimeType"][$i]."; name=".$conf["attachmentName"][$i]."\r\n";
                                $attachment=$attachment."Content-Disposition: attachment; filename=".$conf["attachmentName"][$i]."\r\n";
                                $attachment=$attachment."Content-Transfer-Encoding: base64\r\n";                        
                                $attachment=$attachment."X-Attachment-Id: f_io1ikfii".$i."\r\n";
                                        
                                #將檔案用base64加密                                       
                                $base64fileStr=base64_encode(file_get_contents($conf["attachment"][$i]));
                                
                                #依據規定,每列不得大於70的字元
                                $wordwrapedFileStr=wordwrap($base64fileStr,70,"\r\n",true);
                                
                                #斷行後附加檔案字串
                                $attachment=$attachment."\r\n".$wordwrapedFileStr."\r\n";       
                                        
                                #如果是最後一個附件
                                if($i==count($conf["attachment"])-1){
                                        
                                        #混合資料結尾
                                        $attachment=$attachment.$boundary."\r\n";
                                        
                                        }#if end        
                                                
                                #增加到信件內文的結尾
                                $mailFileContent=$mailFileContent.$attachment;
                                
                                }#for end
                                                                
                        }#if end
                
                #建立要寄送的郵件檔案
                #函式說明:
                #建立暫存目錄與回傳暫存檔案名稱路徑 
                #回傳結果:
                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                #$result["error"],錯誤訊息.
                #$result["function"],當前執行的函數名稱.
                #$result["content"],暫存檔案的路徑與名稱.
                #必填參數:
                #無.
                #可省略參數:
                #無.
                #參考資料:
                #無.
                #備註:
                #無.
                $conf["conffileAccess::createTempFile"]=array();
                $createTempFile=fileAccess::createTempFile($conf["conffileAccess::createTempFile"]);
                unset($conf["conffileAccess::createTempFile"]);
                
                #如果檔案建立失敗
                if($createTempFile["status"]=="false"){

                        #設置錯誤識別
                        $result["status"]="false";

                        #設置錯誤資訊
                        $result["error"]=$createTempFile;

                        #回傳結果
                        return $result;

                        }#if end
                
                #取得要寄送的郵件檔案
                $mailFile=$createTempFile["content"];
                
                #將字串寫入到檔案
                #$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
                #$result["error"],錯誤訊息陣列.
                #必填參數:
                $conf["fileAccess::writeTextIntoFile"]["fileName"]=$mailFile;#爲要編輯的檔案名稱
                $conf["fileAccess::writeTextIntoFile"]["inputString"]=$mailFileHeader.$mailFileContent;#爲要寫入到裏面的內容,若要每筆資料寫入後換行,則可以在字串內容後面加上 \r\n 即可。
                $conf["fileAccess::writeTextIntoFile"]["fileArgu"]=$conf["fileArgu"];
                #可省略參數:
                #$conf["writeMethod"]="a";#爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入。
                #$conf["web"],檔案是否位於網站上"true",若是在檔案系統則為"false",預設為"true".
                $conf["fileAccess::writeTextIntoFile"]["web"]="false";
                $writeTextIntoFile=fileAccess::writeTextIntoFile($conf["fileAccess::writeTextIntoFile"]);
                unset($conf["fileAccess::writeTextIntoFile"]);

                #如果檔案建立失敗
                if($writeTextIntoFile["status"]=="false"){

                        #設置錯誤識別
                        $result["status"]="false";

                        #設置錯誤資訊
                        $result["error"]=$writeTextIntoFile;

                        #回傳結果
                        return $result;

                        }#if end

                #要執行的系統命令
                $paramArray=array();
                
                #設置要用 ssl
                $paramArray[]="--ssl-reqd";

                #如果為 "levelForCheckSSL" 為 "none"
                if($conf["levelForCheckSSL"]==="none"){
                
                        #設置不用確認ssl符合規範
                        $paramArray[]="-k";
                
                        }#if end

                #設置要設定url
                $paramArray[]="--url";
                
                #設置smtp server
                $paramArray[]=$conf["mailServer"];
                
                #設置指定使用者名稱
                $paramArray[]="-u";
                
                #設置使用名稱與密碼
                $paramArray[]=$conf["username"].":".$conf["password"];
                
                #設置要指定寄信來源顯示的名稱
                $paramArray[]="--mail-from";
                
                #設置寄信來源顯示的名稱
                $paramArray[]=$conf["mailerMailDisplay"];
                
                #有幾個收件人就執行幾次
                foreach($conf["receiverMail"] as $mailTo){
                        
                        #指定收件人的參數
                        $paramArray[]="--mail-rcpt";
                        
                        #串接收件人
                        $paramArray[]=$mailTo;
                        
                        }#for end
                
                #指定mail檔案
                $paramArray[]="--upload-file";
                $paramArray[]=$mailFile;
                
                #看過程
                $paramArray[]="-v";
                
                #用curl寄送信件
                #函式說明:
                #呼叫shell執行系統命令,並取得回傳的內容.
                #回傳的結果:
                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                #$result["error"],錯誤訊息陣列.
                #$result["function"],當前執行的函數名稱.
                #$result["cmd"],執行的指令內容.
                #$result["output"],爲執行完二元碼後的輸出陣列.
                #必填參數:
                $conf["external::callShell"]["command"]="curl";#要執行的指令與參
                $conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];
                #可省略參數:
                #$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
                $conf["external::callShell"]["argu"]=$paramArray;
                #$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
                #$conf["enablePrintDescription"]="true";
                #$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容.
                #$conf["printDescription"]="";
                #$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".
                $conf["external::callShell"]["escapeshellarg"]="true";
                #$conf["username"],字串,要用什麼使用者來執行,預設為執行apache的使用者,該參數不適用於apache環境.
                #$conf["username"]="";
                #$conf["password"],字串,與$conf["username"]搭配的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
                #$conf["password"]="";
                #$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要;"false"代表不要,預設為"false".
                #$conf["useScript"]="";
                #$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 ".qbpwcf_tmp/external/callShell/".
                #$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
                #$conf["fileArgu"],字串,變數__FILE__的內容,預設為當前檔案的路徑與名稱.
                #$conf["fileArgu"]=""; 
                #$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false".
                #$conf["external::callShell"]["inBackGround"]="true";
                #參考資料:
                #http://php.net/manual/en/function.exec.php
                $external["callShell"]=external::callShell($conf["external::callShell"]);
                unset($conf["external::callShell"]);

                #如果 $external["callShell"] 等於 "false"
                if($external["callShell"]["status"]==="false"){
                        
                        #如果 "levelForCheckSSL" 為 "loose"
                        if($conf["levelForCheckSSL"]==="loose"){
                        
                                #加上 "-k" 參數,這次不用符合ssl規範
                                $paramArray[]="-k";
                        
                                #用curl寄送信件
                                #函式說明:
                                #呼叫shell執行系統命令,並取得回傳的內容.
                                #回傳的結果:
                                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                                #$result["error"],錯誤訊息陣列.
                                #$result["function"],當前執行的函數名稱.
                                #$result["cmd"],執行的指令內容.
                                #$result["output"],爲執行完二元碼後的輸出陣列.
                                #必填參數:
                                $conf["external::callShell"]["command"]="curl";#要執行的指令與參
                                $conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];
                                #可省略參數:
                                #$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
                                $conf["external::callShell"]["argu"]=$paramArray;
                                #$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
                                #$conf["enablePrintDescription"]="true";
                                #$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容.
                                #$conf["printDescription"]="";
                                #$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".
                                $conf["external::callShell"]["escapeshellarg"]="true";
                                #$conf["username"],字串,要用什麼使用者來執行,預設為執行apache的使用者,該參數不適用於apache環境.
                                #$conf["username"]="";
                                #$conf["password"],字串,與$conf["username"]搭配的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
                                #$conf["password"]="";
                                #$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要;"false"代表不要,預設為"false".
                                #$conf["useScript"]="";
                                #$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 ".qbpwcf_tmp/external/callShell/".
                                #$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
                                #$conf["fileArgu"],字串,變數__FILE__的內容,預設為當前檔案的路徑與名稱.
                                #$conf["fileArgu"]=""; 
                                #$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false".
                                #$conf["external::callShell"]["inBackGround"]="true";
                                #參考資料:
                                #http://php.net/manual/en/function.exec.php
                                $external["callShell"]=external::callShell($conf["external::callShell"]);
                                unset($conf["external::callShell"]);
                        
                                #如果 $external["callShell"] 等於 "false"
                                if($external["callShell"]["status"]==="false"){
                                
                                        #設置錯誤識別
                                        $result["status"]="false";
                                        
                                        #設置錯誤訊息
                                        $result["error"]=$external["callShell"];
                                        
                                        #回傳結果
                                        return $result;
                                
                                        }#if end
                                
                                }#if end
                        
                        #反之
                        else{
                        
                                #設置錯誤識別
                                $result["status"]="false";
                                
                                #設置錯誤訊息
                                $result["error"]=$external["callShell"];
                                
                                #回傳結果
                                return $result;
                                
                                }#else end`
                        
                        }#if end
                        
                #取得較完整的指令
                $result["cmd"]=$external["callShell"]["cmd"];
                
                #移除信件檔案
                #函式說明:
                #移除檔案
                #回傳結果:
                #$result["status"],"true"代表移除成功,"false"代表移除失敗.
                #$result["error"],錯誤訊息陣列
                #$result["warning"],警告訊息陣列
                #$result["function"],當前執行的函數名稱
                #必填參數:
                $conf["fileAccess::delFile"]["fileAddress"]=$mailFile;#要移除檔案的位置
                $conf["fileAccess::delFile"]["fileArgu"]=$conf["fileArgu"];
                $delMailFile=fileAccess::delFile($conf["fileAccess::delFile"]);
                unset($conf["fileAccess::delFile"]);

                #如果移除信件檔案失敗
                if($delMailFile["status"]==="false"){

                        #設置錯誤識別
                        $result["status"]="false";
                        
                        #設置錯誤訊息
                        $result["error"]=$delMailFile;
                        
                        #回傳結果
                        return $result;

                        }#if end

                #可以執行到這邊,就表示十之八九寄信成功了
                $result["status"]="true";
                
                #回傳結果
                return $result;

                }#function curlSmtp end
        
        /*
        #函式說明:
        #使用 linux 的 curl 指令來透過SMTP伺服器寄大量不同內容的信件.
        #回傳結果:
        #$result["status"],寄信的情況,若爲"true",則十之八九沒有問題.
        #$result["error"],錯誤訊息陣列
        #$result["function"],當前執行的函數
        #$result["warning"],警示訊息,一些不會導致失敗但不能說是完美的問題.
        #$result["cmd"],寄信的指令.
        #$result["detailCmd"],較詳細的寄信指令.
        #必填參數:
        #$conf["username"],字串,用來登入郵件伺服器的帳號
        $conf["username"]="";
        #$conf["password"],字串,用來登入郵件伺服器的密碼
        $conf["password"]="";
        #$conf["receiverMail"],二維字串陣列,每個信件的收件人信箱有哪些.
        $conf["receiverMail"]=array(array());
        #$conf["subject"],字串陣列,每封郵件的主題.
        $conf["subject"]=array("");
        #$conf["plainBody"],字串陣列,郵件本文的純文字內容.
        $conf["plainBody"]=array("");
        #$conf["htmlBody"]="";,字串陣列,郵件本文的html內容,多媒體盡量不要用base64的方式來嵌入,因為大部分的郵件服務(Gmail)都不支援,如果是在單機上的郵件軟體就可能有支援,例如:Evolution.
        $conf["htmlBody"]=array("");
        #$conf["fileArgu"],字串,php內建變數「__FILE__」的內容.
        $conf["fileArgu"]=__FILE__;
        #可省略參數:
        #$conf["usernameOnly"],字串,登入的帳號是否只要名稱不要@,預設爲"false"使用完整名稱跟@;反之爲"false".
        #$conf["usernameOnly"]="false";
        #$conf["mailServer"],字串,要使用的SMTP郵件伺服器網址與連接口,預設爲 smtps://smtp.gmail.com:465
        #$conf["mailServer"]="";
        #$conf["mailerMailDisplay"],字串,要顯示的寄件人信箱,預設爲 $conf["username"]
        #$conf["mailerMailDisplay"]="";
        #$conf["mailerNameDisplay"],字串,要顯示的寄件人姓名,預設爲 $conf["username"]
        #$conf["mailerNameDisplay"]="";
        #$conf["receiverMailDisplay"],陣列,每封信要顯示的收件人信箱,預設爲 $conf["receiverMail"] 對應的元素.
        #$conf["receiverMailDisplay"]=array("");
        #$conf["receiverNameDisplay"],陣列,每封信要顯示的收件人姓名,預設爲 $conf["receiverMail"] 對應的元素.
        #$conf["receiverNameDisplay"]=array("");
        #$conf["attachment"],二維陣列,每個信件要寄送的附件路徑與檔案名稱
        #$conf["attachment"]=array(array());
        #$conf["attachmentName"],二維陣列,每個信件要寄送的附件顯示名稱,預設為$conf["attachment"]中的實際檔案名稱.
        #$conf["attachmentName"]=array(array());
        #$conf["attachmentMimeType"],二維陣列,每個信件附件的 mimeType,預設為"application/*".
        #$conf["attachmentMimeType"]array(array());
        #$conf["insecure"],字串,是否允許不安全的tls連線,預設爲"false"不允許,"true"爲允許.
        #$conf["insecure"]="false";
        #參考資料:
        #無.
        #備註:
        #無.
        */
        public static function multiCurlSmtp(&$conf){
                
                #初始化要回傳的結果
                $result=array();

                #儲存當前執行的函數
                $result["function"]=__FUNCTION__;

                #如果 $conf 不為陣列
                if(gettype($conf)!="array"){
                        
                        #設置執行失敗
                        $result["status"]="false";
                        
                        #設置執行錯誤訊息
                        $result["error"][]="\$conf變數須為陣列形態";

                        #如果傳入的參數為 null
                        if($conf==null){
                                
                                #設置執行錯誤訊息
                                $result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
                                
                                }#if end

                        #回傳結果
                        return $result;
        
                        }#if end
        
                #檢查參數
                #函式說明:
                #檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                #$reuslt["error"],執行不正常結束的錯訊息陣列.
                #$result["function"],當前執行的函式名稱.
                #$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
                #$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
                #$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
                #$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
                #$result["argu"],字串陣列,目前輸入的參數名稱陣列.
                #$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
                #$result["notNeedVar"],字串陣列,多餘的參數名稱.
                #必填寫的參數:
                #$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
                $conf["variableCheck::checkArguments"]["varInput"]=&$conf;
                #$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("username","password","receiverMail","subject","plainBody","htmlBody","fileArgu");
                #$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); 
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","array","array","array","array","string");
                #$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
                $conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
                #可以省略的參數:
                #$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
                #$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
                #$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["skipableVariableName"]=array("attachment","attachmentName","attachmentMimeType","mailServer","mailerMailDisplay","mailerNameDisplay","receiverMailDisplay","receiverNameDisplay","insecure","usernameOnly");
                #$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
                $conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array","array","array","string","string","string","array","array","string","string");
                #$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
                $conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,null,null,"smtps://smtp.gmail.com:465","\$conf[\"username\"]","\$conf[\"username\"]","\$conf[\"receiverMail\"]","\$conf[\"receiverMail\"]","false","false");
                #$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
                $conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("subject","plainBody","htmlBody","receiverMail","receiverMailDisplay","receiverNameDisplay");
                #參考資料來源:
                #array_keys=>http://php.net/manual/en/function.array-keys.php
                $checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
                unset($conf["variableCheck::checkArguments"]);
        
                #如果檢查失敗
                if($checkArguments["status"]=="false"){
                        
                        #設置錯誤識別
                        $result["status"]="false";
                        
                        #設置錯誤訊息
                        $result["error"]=$checkArguments;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
        
                #如果檢查不通過
                if($checkArguments["passed"]=="false"){
                        
                        #設置錯誤識別
                        $result["status"]="false";
                        
                        #設置錯誤訊息
                        $result["error"]=$checkArguments;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
        
                #檢查 .curlSmtp 資料夾是否存在
                #函式說明:檢查多個檔案是否存在
                #回傳的結果:
                #$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
                #$result["error"],錯誤訊息陣列.
                #$resutl["function"],當前執行的涵式名稱.
                #$result["allExist"],所有檔案皆存在的識別,"true"代表皆存在,"false"代表沒有全部都存在.
                #$result["varName"][$i],爲第$i個資料夾或檔案的名稱。
                #$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
                #必填參數:
                $conf["fileAccess::checkMultiFileExist"]["fileArray"]=array(".curlSmtp");#要檢查書否存在的檔案有哪些,須爲一維陣列數值。
                $conf["fileAccess::checkMultiFileExist"]["fileArgu"]=$conf["fileArgu"];
                #參考資料來源:
                #http://php.net/manual/en/function.file-exists.php
                #http://php.net/manual/en/control-structures.foreach.php
                $checkMutiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
                unset($conf["fileAccess::checkMultiFileExist"]);
                
                #如果檢查檔案失敗
                if($checkMutiFileExist["status"]=="false"){
                        
                        #設置錯誤識別
                        $result["status"]="false";
                        
                        #設置錯誤訊息
                        $result["error"]=$checkMutiFileExist;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end

                #如果該資料夾不存在
                if($checkMutiFileExist["varExist"][0]=="false"){

                        #則建立該資料夾
                        #函式說明:
                        #建立資料夾,若要建立的資料夾所屬路徑不存在,則會自動嘗試建立,建立後的資料夾也可指定權限.
                        #回傳結果:
                        #$result["status"],"true"爲建立成功,"false"爲建立失敗.
                        #$result["error"],錯誤訊息陣列
                        #必填參數:
                        $conf["fileAccess::createFolderAfterCheck"]["dirPositionAndName"]=".curlSmtp";#新建的位置與名稱
                        $conf["fileAccess::createFolderAfterCheck"]["fileArgu"]=$conf["fileArgu"];
                        #可省略參數:
                        #$conf["fileAccess::createFolderAfterCheck"]["dirPermission"]="";#新建資料夾的權限設定,預設爲0770,亦即擁有者,同群組者可以讀,寫,存取,其他人僅能存取.
                        $createFolderAfterCheck=fileAccess::createFolderAfterCheck($conf["fileAccess::createFolderAfterCheck"]);
                        unset($conf["fileAccess::createFolderAfterCheck"]);
                        
                        #如果 建立資料夾失敗
                        if($createFolderAfterCheck["status"]=="false"){

                                #設置錯誤識別
                                $result["status"]="false";

                                #設置錯誤訊息
                                $result["errot"]=$createFolderAfterCheck;

                                #回傳結果
                                return $result;

                                }#if end

                        }#if end
                
                #初始化寄信的command
                #$mailCmd="";
                
                #初始化寄信的指令
                $mailCmdArray=array();          
                        
                #初始化移除信件檔案的指令
                $delMailFileCmd=array();
                
                #取得 $systemTime     
                $systemTime=time::getMicrotime();

                #要傳送的信件資訊
                $fromInfo="From: ".$conf["mailerNameDisplay"]." <".$conf["mailerMailDisplay"].">\r\n";
                
                #初始化信件的 header
                $mailFileHeader="";
                
                #依據 $conf["receiverMail"] 的數量
                for($i=0;$i<count($conf["receiverMail"]);$i++){
                        
                        #串接寄件人的資訊
                        $mailFileHeader=$mailFileHeader.$fromInfo;
                                
                        #如果第$i筆信件的收件人陣列不存在
                        if(!isset($conf["receiverMail"][$i])){
                                
                                #設置執行不正常
                                $result["status"]="false";
                                
                                #設置錯誤訊息
                                $result["error"][]="第".($i+1)."筆收件人陣列不存在";
                                
                                #回傳結果
                                return $result;
                                
                                }#if end

                        #反之存在但形態不為陣列
                        if(gettype($conf["receiverMail"][$i])!="array"){
                                
                                #設置執行不正常
                                $result["status"]="false";
                                
                                #設置錯誤訊息
                                $result["error"][]="第".($i+1)."筆收件人陣列形態不正確";
                                
                                #回傳結果
                                return $result;
                                
                                }#if end        
                                                
                        #如果第$i筆信件的收件人名稱不存在
                        if(!isset($conf["receiverNameDisplay"][$i])){
                                                                
                                #設為第$i筆信件的收件人陣列
                                $conf["receiverNameDisplay"][$i]=$conf["receiverMail"][$i];
                                                                
                                }#if end
                                
                        #第$i筆信件收件人名稱陣列的第一個元素不存在
                        else if(!isset($conf["receiverNameDisplay"][$i][0])){
                                
                                #設置執行不正常
                                $result["status"]="false";
                                
                                #設置錯誤訊息
                                $result["error"][]="第".($i+1)."筆收件人名稱陣列的第一個收件人名稱不存在";
                                
                                #回傳結果
                                return $result;
                                
                                }#if end
                        
                        #如果第$i筆信件的收件人信箱名稱不存在
                        if(!isset($conf["receiverMailDisplay"][$i])){
                                
                                #設為第$i筆信件的收件人陣列
                                $conf["receiverMailDisplay"][$i]=$conf["receiverMail"][$i];
                                                                
                                }#if end
                                
                        #第$i筆信件收件人信箱名稱陣列的第一個元素不存在
                        else if(!isset($conf["receiverNameDisplay"][$i][0])){
                                
                                #設置執行不正常
                                $result["status"]="false";
                                
                                #設置錯誤訊息
                                $result["error"][]="第".($i+1)."筆收件人信箱名稱陣列的第一個收件人信箱名稱不存在";
                                
                                #回傳結果
                                return $result;
                                
                                }#if end                                                
                                                                
                        #第一個人為主要收件人
                        $mailFileHeader=$mailFileHeader."To: ".$conf["receiverNameDisplay"][$i][0]." "."<".$conf["receiverMailDisplay"][$i][0].">\r\n";                 
                        
                        #如果有其餘收件人
                        if(count($conf["receiverNameDisplay"][$i])>1){
                                
                                #副本寄送處的資訊開始
                                $mailFileHeader=$mailFileHeader."Cc: ";
                                
                                }#if end
                        
                        #針對其餘收件人的地址
                        for($j=1;$j<count($conf["receiverNameDisplay"][$i]);$j++){
                                
                                #如果不是最後一筆
                                if($j!=count($conf["receiverNameDisplay"][$i])-1){
                                        
                                        #串接並加上逗號
                                        $mailFileHeader=$mailFileHeader.$conf["receiverNameDisplay"][$i][$j]." <".$conf["receiverMailDisplay"][$i][$j].">,";
                                        
                                        }#if end
                                
                                #反之是最後一筆
                                else{
                                        
                                        #串接並接上換行符號
                                        $mailFileHeader=$mailFileHeader.$conf["receiverNameDisplay"][$i][$j]." <".$conf["receiverMailDisplay"][$i][$j].">\r\n";
                                        
                                        }#else end                              
                                
                                }#for end
                        
                        #設置信件標題
                        $mailFileHeader=$mailFileHeader."Subject: ".$conf["subject"][$i]."\r\n";
                
                        #設置 MIME-Version
                        $mailFileHeader=$mailFileHeader."MIME-Version: 1.0\r\n";
                        
                        #初始化信件本文
                        $mailFileContent="";
                                
                        #設置信件本文(純文字與html兩種)                             
                        $mailFileContent=$mailFileContent."--001a11c30ce8aec3550533bfa9ab\r\n";
                        $mailFileContent=$mailFileContent."Content-Type: multipart/alternative; boundary=001a11c30ce8aec3480533bfa9a9\r\n";
                        $mailFileContent=$mailFileContent."\r\n";
                        $mailFileContent=$mailFileContent."--001a11c30ce8aec3480533bfa9a9\r\n";
                        $mailFileContent=$mailFileContent."Content-Type: text/plain; charset=UTF-8\r\n";
                        $mailFileContent=$mailFileContent."\r\n";
                        $mailFileContent=$mailFileContent.$conf["plainBody"][$i]."\r\n";
                        $mailFileContent=$mailFileContent."\r\n";
                        $mailFileContent=$mailFileContent."--001a11c30ce8aec3480533bfa9a9\r\n";
                        $mailFileContent=$mailFileContent."Content-Type: text/html; charset=UTF-8\r\n";
                        $mailFileContent=$mailFileContent."\r\n";
                        $mailFileContent=$mailFileContent.$conf["htmlBody"][$i]."\r\n";
                        $mailFileContent=$mailFileContent."\r\n";
                        $mailFileContent=$mailFileContent."--001a11c30ce8aec3480533bfa9a9--\r\n";
                        
                        #如果有設定要上傳附件
                        if(isset($conf["attachment"])){
                                
                                #如果第 $i+1 封信件有指定 附件
                                if(isset($conf["attachment"][$i])){
                                        
                                        #如果類型正確
                                        if(gettype($conf["attachment"][$i])=="array"){
                                                
                                                #依據每個附件
                                                for($j=0;$j<count($conf["attachment"][$i]);$j++){
                                                        
                                                        #初始化寄送附件的語法
                                                        $attachment="";
                                                        
                                                        #確認目標檔案是否存在 #函式說明:檢查多個檔案是否存在 #回傳的結果: 
                                                        #$result["status"],執行正常與否,"true"代表正常,"false"代表不正常. 
                                                        #$result["error"],錯誤訊息陣列. 
                                                        #$resutl["function"],當前執行的涵式名稱. 
                                                        #$result["allExist"],所有檔案皆存在的識別,"true"代表皆存在,"false"代表沒有全部都存在. 
                                                        #$result["varName"][$i],爲第$i個資料夾或檔案的名稱。 
                                                        #$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。 
                                                        #必填參數: 
                                                        $conf["fileAccess::checkMultiFileExist"]["fileArgu"]=$conf["fileArgu"]; 
                                                        $conf["fileAccess::checkMultiFileExist"]["fileArray"]=array($conf["attachment"][$i][$j]);#要檢查書否存在的檔案有哪些,須爲一維陣列數值。 
                                                        #參考資料來源: 
                                                        #http://php.net/manual/en/function.file-exists.php 
                                                        #http://php.net/manual/en/control-structures.foreach.php 
                                                        $checkMutiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]); 
                                                        unset($conf["fileAccess::checkMultiFileExist"]);
                                                                
                                                        #如果檢查失敗
                                                        if($checkMutiFileExist["status"]=="false"){
                                                                
                                                                #設置錯誤識別
                                                                $result["status"]="false";

                                                                #設置錯誤資訊
                                                                $result["error"]=$checkMutiFileExist;

                                                                #回傳結果
                                                                return $result;
                                                                
                                                                }#if end
                                                                
                                                        #如果檔案不存在
                                                        if($checkMutiFileExist["varExist"][0]=="false"){
                                                                
                                                                #設置錯誤識別
                                                                $result["status"]="false";

                                                                #設置錯誤資訊
                                                                $result["error"]=$checkMutiFileExist;

                                                                #回傳結果
                                                                return $result;
                                                                
                                                                }#if end
                                                                
                                                        #如果是第一個附件
                                                        if($j==0){
                                                                
                                                                #在前面加上 multipart/mixed 的 boundary
                                                                $mailFileContent="Content-Type: multipart/mixed; boundary=001a11c30ce8aec3550533bfa9ab\r\n\r\n".$mailFileContent;
                                                                
                                                                }#if end
                                                                
                                                        #如果 $conf["attachmentName"][$i] 不存在
                                                        if(!isset($conf["attachmentName"][$i])){
                                                                
                                                                #涵是說明:
                                                                #取得檔案路徑字串的路徑與檔案的名稱與檔案副檔名
                                                                #回傳的結果:
                                                                #$result["status"],執行是否正常,"true"正常,"false"代表不正常.
                                                                #$result["error"],錯誤訊息.
                                                                #$result["function"],當前執行的函式名稱.
                                                                #$result["filePath"],路徑字串.
                                                                #$result["fileName"],檔案名稱字串.
                                                                #$result["fileExtention"],檔案的副檔名.
                                                                #$result["fullFileName"],含副檔名的檔案名稱.
                                                                #$result["fullFilePathAndName"],完整的檔案路徑(含副檔名).
                                                                #必填參數:
                                                                #$conf["fileAddressAndName"],字串,檔案名稱與其路徑.
                                                                $conf["fileAccess::getFileAddressAndNameAndFileExtention"]["fileAddressAndName"]=$conf["attachment"][$i][$j];
                                                                #可省略的參數:
                                                                #無.
                                                                $getFileAddressAndNameAndFileExtention=fileAccess::getFileAddressAndNameAndFileExtention($conf["fileAccess::getFileAddressAndNameAndFileExtention"]);
                                                                unset($conf["fileAccess::getFileAddressAndNameAndFileExtention"]);
                                                                                
                                                                #如果解析檔案資訊失敗         
                                                                if($getFileAddressAndNameAndFileExtention["status"]=="false"){
                                                                        
                                                                        #設置錯誤識別
                                                                        $result["status"]="false";

                                                                        #設置錯誤資訊
                                                                        $result["error"]=$getFileAddressAndNameAndFileExtention;

                                                                        #回傳結果
                                                                        return $result;
                                                                        
                                                                        }#if end                        
                                                                                                
                                                                #設定附件名稱
                                                                $conf["attachmentName"][$i][$j]=$getFileAddressAndNameAndFileExtention["fullFileName"];
                                                                
                                                                }#if end
                                                                
                                                        #反之如果 $conf["attachmentName"][$i][$j] 不存在
                                                        else if(!isset($conf["attachmentName"][$i][$j])){
                                                                
                                                                #涵是說明:
                                                                #取得檔案路徑字串的路徑與檔案的名稱與檔案副檔名
                                                                #回傳的結果:
                                                                #$result["status"],執行是否正常,"true"正常,"false"代表不正常.
                                                                #$result["error"],錯誤訊息.
                                                                #$result["function"],當前執行的函式名稱.
                                                                #$result["filePath"],路徑字串.
                                                                #$result["fileName"],檔案名稱字串.
                                                                #$result["fileExtention"],檔案的副檔名.
                                                                #$result["fullFileName"],含副檔名的檔案名稱.
                                                                #$result["fullFilePathAndName"],完整的檔案路徑(含副檔名).
                                                                #必填參數:
                                                                #$conf["fileAddressAndName"],字串,檔案名稱與其路徑.
                                                                $conf["fileAccess::getFileAddressAndNameAndFileExtention"]["fileAddressAndName"]=$conf["attachment"][$i][$j];
                                                                #可省略的參數:
                                                                #無.
                                                                $getFileAddressAndNameAndFileExtention=fileAccess::getFileAddressAndNameAndFileExtention($conf["fileAccess::getFileAddressAndNameAndFileExtention"]);
                                                                unset($conf["fileAccess::getFileAddressAndNameAndFileExtention"]);
                                                                                
                                                                #如果解析檔案資訊失敗         
                                                                if($getFileAddressAndNameAndFileExtention["status"]=="false"){
                                                                        
                                                                        #設置錯誤識別
                                                                        $result["status"]="false";

                                                                        #設置錯誤資訊
                                                                        $result["error"]=$getFileAddressAndNameAndFileExtention;

                                                                        #回傳結果
                                                                        return $result;
                                                                        
                                                                        }#if end                        
                                                                                                
                                                                #設定附件名稱
                                                                $conf["attachmentName"][$i][$j]=$getFileAddressAndNameAndFileExtention["fullFileName"];
                                                                
                                                                }#if end
                                                                
                                                        #如果 $conf["attachmentMimeType"][$i][$j] 不存在
                                                        if(!isset($conf["attachmentMimeType"][$i])){
                                                                
                                                                #設定檔案類型
                                                                $conf["attachmentMimeType"][$i][$j]="application/*";
                                                                                                                                        
                                                                }#if end        
                                                                
                                                        #反之如果 $conf["attachmentMimeType"][$i][$j] 不存在     
                                                        else if(!isset($conf["attachmentMimeType"][$i][$j])){
                                                                
                                                                $conf["attachmentMimeType"][$i][$j]="application/*";
                                                                
                                                                }#if end
                                                        
                                                        #加上寄送附件的語法
                                                        $attachment=$attachment."--001a11c30ce8aec3550533bfa9ab\r\n";
                                                        $attachment=$attachment."Content-Type: ".$conf["attachmentMimeType"][$i][$j]."; name=".$conf["attachmentName"][$i][$j]."\r\n";
                                                        $attachment=$attachment."Content-Disposition: attachment; filename=".$conf["attachmentName"][$i][$j]."\r\n";
                                                        $attachment=$attachment."Content-Transfer-Encoding: base64\r\n";                        
                                                        $attachment=$attachment."X-Attachment-Id: f_io1ikfii".$i."_".$j."\r\n";
                                                                
                                                        #將檔案用base64加密                                       
                                                        $base64fileStr=base64_encode(file_get_contents($conf["attachment"][$i][$j]));
                                                        
                                                        #依據規定,每列不得大於70的字元
                                                        $wordwrapedFileStr=wordwrap($base64fileStr,70,"\r\n",true);
                                                        
                                                        #斷行後附加檔案字串
                                                        $attachment=$attachment."\r\n".$wordwrapedFileStr."\r\n";       
                                                                
                                                        #如果是最後一個附件
                                                        if($j==count($conf["attachment"][$i])-1){
                                                                
                                                                #混合資料結尾
                                                                $attachment=$attachment."--001a11c30ce8aec3550533bfa9ab--\r\n";
                                                                
                                                                }#if end        
                                                                        
                                                        #增加到信件內文的結尾
                                                        $mailFileContent=$mailFileContent.$attachment;
                                                        
                                                        }#for end
                                                
                                                }#if end
                                        
                                        }#if end
                                                                        
                                }#if end
                        
                        #要寄送的郵件檔案路徑與名稱
                        $mailFile=".curlSmtp/mail_at_".$systemTime.".mail";     
                                
                        #建立要寄送的郵件檔案
                        #將字串寫入到檔案
                        #回傳結果:
                        #$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
                        #$result["error"],錯誤訊息陣列.
                        #$result["function"],當前執行的函數名稱.
                        #$result["fileInfo"],實際上寫入的檔案資訊陣列.
                        #$result["fileInfo"]["createdFileName"],建立好的檔案名稱.
                        #$result["fileInfo"]["createdFilePath"],檔案建立的路徑.
                        #$result["fileInfo"]["createdFilePathAndName"].建立好的檔案名稱與路徑.
                        #必填參數:
                        $conf["fileAccess::writeTextIntoFile"]["fileName"]=$mailFile;#爲要編輯的檔案名稱
                        $conf["fileAccess::writeTextIntoFile"]["inputString"]=$mailFileHeader.$mailFileContent;#爲要寫入到裏面的內容,若要每筆資料寫入後換行,則可以在字串內容後面加上 \r\n 即可。
                        $conf["fileAccess::writeTextIntoFile"]["fileArgu"]=$conf["fileArgu"];
                        #可省略參數:
                        #$conf["writeMethod"],字串,爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入.
                        #$conf["writeMethod"]="a";
                        #$conf["checkRepeat"],字串,"true"代表建立檔案之前要先檢查檔案是否存在,若存在則在原名稱後面加上從(1)開始的編號.
                        $conf["fileAccess::writeTextIntoFile"]["checkRepeat"]="true";
                        #$conf["filenameExtensionStartPoint"],字串,檔案的副檔名是從倒數第幾個小數點(dot)開始,預設為"1",最後一個小數點
                        #$conf["filenameExtensionStartPoint"]="";
                        #$conf["repeatNameRule"],字串,遇到相同名稱的檔案要如何加上識別的編號,編號用「\$i」表示,預設為"(\$i)"
                        $conf["fileAccess::writeTextIntoFile"]["repeatNameRule"]="_\$i";
                        $writeTextIntoFile=fileAccess::writeTextIntoFile($conf["fileAccess::writeTextIntoFile"]);
                        unset($conf["fileAccess::writeTextIntoFile"]);
        
                        #如果檔案建立失敗
                        if($writeTextIntoFile["status"]=="false"){

                                #設置錯誤識別
                                $result["status"]="false";

                                #設置錯誤資訊
                                $result["error"]=$writeTextIntoFile;

                                #回傳結果
                                return $result;

                                }#if end
                        
                        #取得建立好的檔案名稱
                        $mailFile=$writeTextIntoFile["fileInfo"]["createdFilePathAndName"];
                        
                        #初始化收件人字串
                        $rcptStr="";

                        #有幾個收件人就執行幾次
                        foreach($conf["receiverMail"][$i] as $mailTo){
                                
                                #串接收件人
                                $rcptStr=$rcptStr." --mail-rcpt \"".$mailTo."\"";
                                
                                }#for end

                        #初始化允許不安全連線的字串
                        $insecure="";

                        #如果允許不安全的連線
                        if($conf["insecure"]==="true"){
                                
                                #設置允許不安全連線
                                $insecure="--insecure";
                                
                                }#if end

                        #如果登入帳號不用@
                        if($conf["usernameOnly"]==="true"){
                                
                                #尋找有無 "@"
                                $at=strpos($conf["username"],"@");
                                
                                #如果有找到
                                if($at!==false){
                                        
                                        #取得不含 @... 的帳戶名稱
                                        $conf["username"]=substr($conf["username"],0,$at);
                                        
                                        }#if end
                                
                                }#if end

                        #設置要執行的系統命令(寄信)
                        $cmdString="curl --ssl --anyauth -1 ".$insecure." --url \"".$conf["mailServer"]."\" -u \"".$conf["username"].":".$conf["password"]."\" --mail-from \"".$conf["mailerMailDisplay"]."\" $rcptStr --upload-file \"".$mailFile."\" -v";
                        
                        #取得寄信的指令
                        $mailCmdArray[]=$cmdString;             
                        
                        #取得移除信件檔案的指令
                        $delMailFileCmd[]="rm \"".$mailFile."\"";
                                                
                        #清空 $mailFileHeader
                        $mailFileHeader="";
                
                        }#for end       
                        
                #用curl寄送信件
                #函式說明:
                #運用nohup與&來達到雖依序執行但不等待前一個指令執行完再執行下一個指令,形成假多工的執行每個指令.
                #回傳結果: 
                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                #$result["error"],錯誤訊息陣列.
                #$result["function"],當前執行的函數名稱.
                #$result["cmd"],執行的指令內容.
                #$result["output"],爲執行完二元碼後的輸出陣列.
                #必填參數:
                #$conf["command"],字串陣列,要執行的指令與.
                $conf["external::multiThreadsShell"]["command"]=$mailCmdArray;
                #$conf["fileArgu"],字串,變數__FILE__的內容.
                $conf["external::multiThreadsShell"]["fileArgu"]=$conf["fileArgu"];             
                #可省略參數:
                #$conf["argu"],二維陣列字串,每個指令搭配的參數,預設為空陣列.
                #$conf["argu"]=array(array());
                #$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
                #$conf["enablePrintDescription"]="true";
                #$conf["printDescription"],字串陣列,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容.
                #$conf["printDescription"]=array("");
                #$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".
                #$conf["escapeshellarg"]="false";
                #$conf["username"],字串陣列,每個指令要用什麼使用者來執行,預設為執行php使用者,該參數不適用於apache環境.
                #$conf["username"]=array("");
                #$conf["password"],字串陣列,與$conf["username"]搭配的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
                #$conf["password"]=array("");
                $multiThreadsShell=external::multiThreadsShell($conf["external::multiThreadsShell"]);
                unset($conf["external::multiThreadsShell"]);
                
                #如果寄信失敗
                if($multiThreadsShell["status"]=="false")
                {
                        #設置錯誤識別
                        $result["status"]="false";

                        #設置錯誤資訊
                        $result["error"]=$multiThreadsShell;

                        #回傳結果
                        return $result;
                }
                
                #取得執行的指令
                $result["cmd"]=$multiThreadsShell["cmd"];
                
                /*
                                        
                #移除信件檔案
                #函式說明:
                #運用nohup與&來達到雖依序執行但不等待前一個指令執行完再執行下一個指令,形成假多工的執行每個指令.
                #回傳結果: 
                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                #$result["error"],錯誤訊息陣列.
                #$result["function"],當前執行的函數名稱.
                #$result["cmd"],執行的指令內容.
                #$result["output"],爲執行完二元碼後的輸出陣列.
                #必填參數:
                #$conf["command"],字串陣列,要執行的指令與.
                $conf["external::multiThreadsShell"]["command"]=$delMailFileCmd;
                #$conf["fileArgu"],字串,變數__FILE__的內容.
                $conf["external::multiThreadsShell"]["fileArgu"]=$conf["fileArgu"];             
                #可省略參數:
                #$conf["argu"],二維陣列字串,每個指令搭配的參數,預設為空陣列.
                #$conf["argu"]=array(array());
                #$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
                #$conf["enablePrintDescription"]="true";
                #$conf["printDescription"],字串陣列,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容.
                #$conf["printDescription"]=array("");
                #$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".
                #$conf["escapeshellarg"]="false";
                #$conf["username"],字串陣列,每個指令要用什麼使用者來執行,預設為執行php使用者,該參數不適用於apache環境.
                #$conf["username"]=array("");
                #$conf["password"],字串陣列,與$conf["username"]搭配的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
                #$conf["password"]=array("");
                $multiThreadsShell=external::multiThreadsShell($conf["external::multiThreadsShell"]);
                unset($conf["external::multiThreadsShell"]);
                
                #如果移除信件檔案失敗
                if($multiThreadsShell["status"]=="false"){
                        
                        #設置錯誤識別
                        $result["status"]="false";

                        #設置錯誤資訊
                        $result["error"]=$multiThreadsShell;

                        #回傳結果
                        return $result;
                
                        }
                
                */                      
                        
                #設置執行正常
                $result["status"]="true";
                                        
                #回傳結果
                return $result;
                                        
                }#function multiCurlSmtp end
        
        /*
        #函式說明:
        #透過php的mail函數寄信
        #回傳結果:
        #$result["status"],寄信的情況,若爲"true",則十之八九沒有問題.
        #$result["error"],錯誤訊息陣列
        #$result["function"],當前執行的函數
        #必填參數:
        #$conf["to"],字串陣列,收件人們的信箱.
        $conf["to"]=array();
        #$conf["subject"],字串,郵件標題.
        $conf["subject"]="";
        #$conf["content"],字串,要寄送的訊息內容.
        $conf["content"]="";
        #可省略參數: 
        #$conf["mailerEmail"],字串,顯示的寄件人.
        #$conf["mailerEmail"]="";
        #參考資料:
        #mail=>https://www.php.net/manual/en/function.mail.php
        #Internet Message Format=>http://www.faqs.org/rfcs/rfc2822
        #備註:
        #無.
        */
        public static function sendMail(&$conf){
                
                #初始化要回傳的結果
                $result=array();

                #儲存當前執行的函數
                $result["function"]=__FUNCTION__;

                #如果 $conf 不為陣列
                if(gettype($conf)!="array"){
                        
                        #設置執行失敗
                        $result["status"]="false";
                        
                        #設置執行錯誤訊息
                        $result["error"][]="\$conf變數須為陣列形態";

                        #如果傳入的參數為 null
                        if($conf==null){
                                
                                #設置執行錯誤訊息
                                $result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
                                
                                }#if end

                        #回傳結果
                        return $result;
        
                        }#if end
        
                #檢查參數
                #函式說明:
                #檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                #$reuslt["error"],執行不正常結束的錯訊息陣列.
                #$result["function"],當前執行的函式名稱.
                #$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
                #$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
                #$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
                #$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
                #$result["argu"],字串陣列,目前輸入的參數名稱陣列.
                #$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
                #$result["notNeedVar"],字串陣列,多餘的參數名稱.
                #必填寫的參數:
                #$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
                $conf["variableCheck::checkArguments"]["varInput"]=&$conf;
                #$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("to","subject","content");
                #$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); 
                $conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array","string","string");
                #$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
                $conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
                #可以省略的參數:
                #$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
                #$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
                #$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
                $conf["variableCheck::checkArguments"]["skipableVariableName"]=array("mailerEmail");
                #$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
                $conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
                #$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
                $conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null);
                #$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
                #$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("subject","plainBody","htmlBody","receiverMail","receiverMailDisplay","receiverNameDisplay");
                #參考資料來源:
                #array_keys=>http://php.net/manual/en/function.array-keys.php
                $checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
                unset($conf["variableCheck::checkArguments"]);
        
                #如果檢查失敗
                if($checkArguments["status"]=="false"){
                        
                        #設置錯誤識別
                        $result["status"]="false";
                        
                        #設置錯誤訊息
                        $result["error"]=$checkArguments;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
        
                #如果檢查不通過
                if($checkArguments["passed"]=="false"){
                        
                        #設置錯誤識別
                        $result["status"]="false";
                        
                        #設置錯誤訊息
                        $result["error"]=$checkArguments;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
                
                #函式說明:
                #將一維陣列轉換為用特定符號間隔的字串,ex:array("1","2","3") to "a;b;c;".
                #回傳的結果:
                #$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
                #$result["function"],當前執行的function名稱
                #$result["error"],錯誤訊息陣列.
                #$result["content"],處理好的字串.
                #$result["argu"],使用的參數.
                #必填參數:
                #$conf["inputArray"],字串陣列,要轉成字串的一維陣列.
                $conf["arrays::arrayToString"]["inputArray"]=$conf["to"];
                #可省略參數:
                #$conf["spiltSymbol"],字串,用來區隔字串的符號,預設為;
                $conf["arrays::arrayToString"]["spiltSymbol"]=", ";
                #$conf["skipEnd"],字串,結尾是否不要加上符號,預設為"false",要加上符號,"true"代表不要加上符號。
                $conf["arrays::arrayToString"]["skipEnd"]="true";
                #參考資料:
                #無.
                #備註:
                #無.
                $arrayToString=arrays::arrayToString($conf["arrays::arrayToString"]);
                unset($conf["arrays::arrayToString"]);
                
                #如果檢查失敗
                if($arrayToString["status"]=="false"){
                        
                        #設置錯誤識別
                        $result["status"]="false";
                        
                        #設置錯誤訊息
                        $result["error"]=$arrayToString;
                        
                        #回傳結果
                        return $result;
                        
                        }#if end
                
                $to = $arrayToString["content"];
                $subject = $conf["subject"];
                $message = $conf["content"];
                
                # In case any of our lines are larger than 70 characters, we should use wordwrap()
                $message = wordwrap($message, 70, "\r\n");
                
                #初始化mail header為空
                $headers = "";
                
                #如果有設置寄件人資訊
                if(isset($conf["mailerEmail"])){
                
                        #設置寄件人資訊
                        $headers = "From: ".$conf["mailerEmail"];
                
                        }#if end
                
                #寄信
                $mailResult=mail($to, $subject, $message, $headers);
                        
                #初始化執行正常
                $result["status"]="true";       
                        
                #如果寄信失敗
                if(!$mailResult){
                        
                        #設置執行不正常
                        $result["status"]="false";
                
                        #回傳結果
                        return $result;
                
                        }#if end
                        
                #回傳結果
                return $result; 
                        
                }#function sendMail end
        
        }#class mail end

?>