Rev 548 | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?php/*QBPWCF, Quick Build PHP website Component base on Fedora Linux.Copyright (C) 2015~2024 Min-Jhin,ChenThis file is part of QBPWCF.QBPWCF is free software: you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe 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 ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with QBPWCF. If not, see <http://www.gnu.org/licenses/>.*/#使用 qbpwcf 命名空間namespace qbpwcf;#匯入套件require_once("qbpwcf/allInOne.php");#qbpwcf用的javascript$qbpwcfJavaScript=javaScript::qbpwcfJavaScript();#建議的log位置$logFile=$_SERVER["DOCUMENT_ROOT"].$_SERVER["PHP_SELF"].".log";#函式說明:#使用 curl 來透過SMTP伺服器寄信#回傳結果:#$result["status"],寄信的情況,若爲"true",則十之八九沒有問題.#$result["error"],錯誤訊息陣列#$result["function"],當前執行的函數#$result["warning"],警示訊息,一些不會導致失敗但不能說是完美的問題.#$result["cmd"],寄信的指令.#$result["detailCmd"],較詳細的寄信指令.#必填參數:#$conf["username"],字串,用來登入郵件伺服器的帳號$conf["username"]="aesopowercms@gmail.com";#$conf["password"],字串,用來登入郵件伺服器的密碼$conf["password"]="gdmvelegbezyfcuf";#$conf["receiverMail"],陣列,收件人的信箱$conf["receiverMail"]=array("tcfxfzoi@gmail.com","tcfxfzoi+1@gmail.com");#$conf["subject"],字串,郵件的主題$conf["subject"]="test qbpwcf mail::curlSmtp function";#$conf["plainBody"],字串,郵件本文的純文字內容.$conf["plainBody"]="test qbpwcf mail::curlSmtp function";#$conf["htmlBody"]="";,字串,郵件本文的html內容,多媒體盡量不要用base64的方式來嵌入,因為大部分的郵件服務(Gmail)都不支援,如果是在單機上的郵件軟體就可能有支援,例如:Evolution.$conf["htmlBody"]="<div style=\"color:red\">test qbpwcf mail::curlSmtp function</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"]="";##$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();#範例語句:#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#備註:#信件的內容格式有錯,導致本文無法顯示.$curlSmtp=mail::curlSmtp($conf);unset($conf);#debugvar_dump($curlSmtp);?>