Subversion Repositories php-qbpwcf

Rev

Blame | Last modification | View Log | RSS feed

<?php

#指派命名空間
namespace qbpwcf;

#匯入外部套件
include("../allInOne.php");

#說明正在測試的內容
echo"<hr>mail::mailTo - testCase 1";

/*

#涵式說明:
#用imap協定寄信
#回傳的變數:
#$result["status"],寄信的情況,"true"爲成功,"false"爲失敗.
#$result["error"],錯誤訊息陣列
#$result["function"],當前執行的函數
#必填的參數:
$conf["username"]="tcfxfzoi@gmail.com";#郵件服務的登入帳號
$conf["password"]="superfedoralinux";#郵件服務的登入密碼
$conf["receiver"]="tcfxfzoi@gmail.com";#收件着
$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
var_dump(mail::mailTo($conf));
unset($conf);

*/

#說明正在測試的內容
echo"<hr>mail::curlSmtp - testCase 1";

/*

#圖片
#函數說明:
#用data:mimeType;base64,imgVar的形式來提供圖片的連結,亦即圖片儲存在變數裡面.
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$result["error"],錯誤訊息
#$result["content"],語法
#$result["function"],當前執行的函數名稱 
#必填參數:
#$conf["imgPosition"],要轉存成2元碼的圖片檔案位置與名稱
$conf["imgPosition"]="mailT/這是測試用的圖片.png";
$conf["fileArgu"]=__FILE__;
#可省略參數:
#$conf["alt"],若沒有圖片要用什麼文字顯示。
#$conf["alt"]="";
#$conf["class"],圖片要套用的css樣式名稱.
#$conf["class"]="";
#$conf["mimeType"],2元碼的內容是什麼,預設為"image/png".
#$conf["mimeType"]="image/*";
#$conf["compressType"],2元碼壓縮的方式,預設為"base64".
#$conf["compressType"]="base64";
#$conf["delImg"],讀取完圖片檔案後,要移除圖片嗎?"true"代表要移除,"false"代表不要移除,預設為"false".
#$conf["delImg"]="false";
#參考資料:
#將檔案用字串變數儲存起來=>http://php.net/manual/en/function.file-get-contents.php
#壓縮2元碼=>http://php.net/manual/en/function.base64-encode.php
$img=img::data($conf);
unset($conf);

#如果將圖片轉換成 data:mimeType;base64,imgVar 的形式失敗 
if($img["status"]=="false"){
        
        #印出錯誤訊息
        var_dump($img);
        
        #停止執行
        exit;
        
        }#if end
        
#涵式說明:
#放置可以套用css樣式的圖片
#回傳的結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$result["error"],錯誤訊息陣列
#$result["function"],當前函數執行的名稱
#$result["content"],印出圖片的語法。            
#必填的參數:
$conf["position"]="https://start.fedoraproject.org/static/images/fedora-logo.png";#圖片位置
#可省略的參數:
#$conf["alt"]="";#若沒有圖片要用什麼文字顯示。
#$conf["class"]="";#要套用的css樣式類別名稱。
$fedoraLogo=img::show($conf);
unset($conf);

#如果放置圖片的語法
if($fedoraLogo["status"]=="false"){
        
        #印出錯誤訊息
        var_dump($fedoraLogo);
        
        #停止執行
        exit;
        
        }#if end
        
#涵式說明:
#使用 curl 來透過SMTP伺服器寄信
#回傳的接結果:
#$result["status"],寄信的情況,若爲"true",則十之八九沒有問題.
#$result["error"],錯誤訊息陣列
#$result["function"],當前執行的函數
#$result["warning"],警示訊息,一些不會導致失敗但不能說是完美的問題.
#$result["output"],寄送信件時的處理訊息.
#$result["cmd"],寄信的語法
#必填的參數:
$conf["username"]="tcfxfzoi@gmail.com";#用來登入郵件伺服器的帳號
$conf["password"]="superfedoralinux";#用來登入郵件伺服器的密碼
$conf["receiverMail"]=array("tcfxfzoi@gmail.com","tcfxfzoi@hotmail.com","tcfxfzoi@yahoo.com.tw");#收件人的信箱
$conf["subject"]="系統測試";#郵件的主題
#$conf["plainBody"],字串,郵件本文的純文字內容.
$conf["plainBody"]="此爲測試信件可以忽略!";
#$conf["htmlBody"]="";,字串,郵件本文的html內容,多媒體盡量不要用base64的方式來嵌入,因為大部分的郵件服務(Gmail)都不支援,如果是在單機上的郵件軟體就可能有支援,例如:Evolution.
$conf["htmlBody"]="<h1>此爲測試信件可以忽略!</h1>\r\n".$img["content"];
#$conf["fileArgu"],字串,php內建變數「__FILE__」的內容.
$conf["fileArgu"]=__FILE__;
#可省略的參數:
#$conf["mailServer"]="";#要使用的SMTP郵件伺服器網址與連接口,預設爲 smtps://smtp.gmail.com:465
#$conf["mailerMailDisplay"]="";#要顯示的寄件人信箱,預設爲 $conf["username"]
#$conf["mailerNameDisplay"]="";#要顯示的寄件人姓名,預設爲 $conf["username"]
#$conf["receiverMailDisplay"]="";#要顯示的收件人信箱,預設爲 $conf["receiverMail"]
#$conf["receiverNameDisplay"]="";#要顯示的收件人姓名,預設爲 $conf["receiverMail"]
#$conf["attachment"],陣列,每個要寄送的附件路徑與檔案名稱
$conf["attachment"]=array("mailT/fedoraBear.png","mailT/fileAccessT.tar");
#$conf["attachmentName"],陣列,每個要寄送的附件顯示名稱,預設為$conf["attachment"]中的實際檔案名稱.
#$conf["attachmentName"]=array();
#$conf["attachmentMimeType"],陣列,每個附件的 mimeType,預設為"application/*".
#$conf["attachmentMimeType"]array();
#範例語句:
#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
#本文~
#參考資料來源:
#http://stackoverflow.com/questions/14722556/using-curl-to-send-email
var_dump(mail::curlSmtp($conf));
#mail::curlSmtp($conf);
unset($conf);

*/

#說明正在測試的內容
echo"<hr>mail::multiCurlSmtp - testCase 1";

/*

#涵式說明:
#使用 linux 的 curl 指令來透過SMTP伺服器寄大量不同內容的信件.
#回傳的接結果:
#$result["status"],寄信的情況,若爲"true",則十之八九沒有問題.
#$result["error"],錯誤訊息陣列
#$result["function"],當前執行的函數
#$result["warning"],警示訊息,一些不會導致失敗但不能說是完美的問題.
#$result["cmd"],寄信的指令.
#$result["detailCmd"],較詳細的寄信指令.
#必填的參數:
#$conf["username"],字串,用來登入郵件伺服器的帳號
$conf["username"]="tcfxfzoi@gmail.com";
#$conf["password"],字串,用來登入郵件伺服器的密碼
$conf["password"]="superfedoralinux";
#$conf["receiverMail"],二維字串陣列,每個信件的收件人信箱有哪些.
$conf["receiverMail"]=array(array("tcfxfzoi@gmail.com","tcfxfzoi@yahoo.com.tw","tcfxfzoi@hotmail.com"),array("tcfxfzoi@gmail.com","tcfxfzoi@yahoo.com.tw","tcfxfzoi@hotmail.com"),array("tcfxfzoi@gmail.com","tcfxfzoi@yahoo.com.tw","tcfxfzoi@hotmail.com"));
#$conf["subject"],字串陣列,每封郵件的主題.
$conf["subject"]=array("mail1","mail2","mail3");
#$conf["plainBody"],字串陣列,郵件本文的純文字內容.
$conf["plainBody"]=array("Hello world","Hello world","Hello world");
#$conf["htmlBody"]="";,字串陣列,郵件本文的html內容,多媒體盡量不要用base64的方式來嵌入,因為大部分的郵件服務(Gmail)都不支援,如果是在單機上的郵件軟體就可能有支援,例如:Evolution.
$conf["htmlBody"]=array("<div style=\"color:red\">Hello World</div>","<div style=\"color:red\">Hello World</div>","<div style=\"color:red\">Hello World</div>");
#$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"]=array("");
#$conf["receiverNameDisplay"],陣列,每封信要顯示的收件人姓名,預設爲 $conf["receiverMail"] 對應的元素.
#$conf["receiverNameDisplay"]=array("");
#$conf["attachment"],二維陣列,每個信件要寄送的附件路徑與檔案名稱
$conf["attachment"]=array(array("fileAccessT.tar","fedoraBear.png","資館周行前會資建股報告.swf"),array("fileAccessT.tar","fedoraBear.png","資館周行前會資建股報告.swf"),array("fileAccessT.tar","fedoraBear.png","資館周行前會資建股報告.swf"));
#$conf["attachmentName"],二維陣列,每個信件要寄送的附件顯示名稱,預設為$conf["attachment"]中的實際檔案名稱.
#$conf["attachmentName"]=array(array());
#$conf["attachmentMimeType"],二維陣列,每個信件附件的 mimeType,預設為"application/*".
#$conf["attachmentMimeType"]array(array());
#備註:
#建構中...
var_dump(mail::multiCurlSmtp($conf));
unset($conf);
  
*/              

#說明正在測試的內容
echo"<hr>mail::multiCurlSmtp - testCase 2";

/*

#涵式說明:
#使用 linux 的 curl 指令來透過SMTP伺服器寄大量不同內容的信件.
#回傳的接結果:
#$result["status"],寄信的情況,若爲"true",則十之八九沒有問題.
#$result["error"],錯誤訊息陣列
#$result["function"],當前執行的函數
#$result["warning"],警示訊息,一些不會導致失敗但不能說是完美的問題.
#$result["cmd"],寄信的指令.
#$result["detailCmd"],較詳細的寄信指令.
#必填的參數:
#$conf["username"],字串,用來登入郵件伺服器的帳號
$conf["username"]="jeff_chen@handlink.com.tw";
#$conf["password"],字串,用來登入郵件伺服器的密碼
$conf["password"]="16363914";
#$conf["receiverMail"],二維字串陣列,每個信件的收件人信箱有哪些.
$conf["receiverMail"]=array(array("jeff_chen@handlink.com.tw","tcfxfzoi@gmail.com","jeffcheninhl@gmail.com"));
#$conf["subject"],字串陣列,每封郵件的主題.
$conf["subject"]=array("mail");
#$conf["plainBody"],字串陣列,郵件本文的純文字內容.
$conf["plainBody"]=array("Hello world");
#$conf["htmlBody"]="";,字串陣列,郵件本文的html內容,多媒體盡量不要用base64的方式來嵌入,因為大部分的郵件服務(Gmail)都不支援,如果是在單機上的郵件軟體就可能有支援,例如:Evolution.
$conf["htmlBody"]=array("<div style=\"color:red\">Hello World</div>");
#$conf["fileArgu"],字串,php內建變數「__FILE__」的內容.
$conf["fileArgu"]=__FILE__;
#可省略的參數:
#$conf["usernameOnly"],字串,登入的帳號是否只要名稱不要@,預設爲"false"使用完整名稱跟@;反之爲"false".
$conf["usernameOnly"]="true";
#$conf["mailServer"],字串,要使用的SMTP郵件伺服器網址與連接口,預設爲 smtps://smtp.gmail.com:465
$conf["mailServer"]="smtps://mail.handlink.com.tw:465";
#$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("fileAccessT.tar","fedoraBear.png","資館周行前會資建股報告.swf"),array("fileAccessT.tar","fedoraBear.png","資館周行前會資建股報告.swf"),array("fileAccessT.tar","fedoraBear.png","資館周行前會資建股報告.swf"));
#$conf["attachmentName"],二維陣列,每個信件要寄送的附件顯示名稱,預設為$conf["attachment"]中的實際檔案名稱.
#$conf["attachmentName"]=array(array());
#$conf["attachmentMimeType"],二維陣列,每個信件附件的 mimeType,預設為"application/*".
#$conf["attachmentMimeType"]array(array());
#$conf["insecure"],字串,是否允許不安全的tls連線,預設爲"false"不允許,"true"爲允許.
$conf["insecure"]="true";
#備註:
#建構中...
var_dump(mail::multiCurlSmtp($conf));
unset($conf);
  
*/              

#說明正在測試的內容
echo"<hr>mail::sendMail - testCase 1";

/*

#函式說明:
#透過php的mail函數寄信
#回傳內容:
#
#必填參數:
#
#可省略參數: 
#
#參考資料來源:
#mail=>http://php.net/manual/en/function.mail.php
#Internet Message Format=>http://www.faqs.org/rfcs/rfc2822.html
#備註:
#建構中
var_dump(mail::sendMail());

*/      

?>