Subversion Repositories qbpwcf-lib(archive)

Rev

Rev 548 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
548 liveuser 1
<?php
2
 
3
/*
4
 
5
        QBPWCF, Quick Build PHP website Component base on Fedora Linux.
636 liveuser 6
    Copyright (C) 2015~2024 Min-Jhin,Chen
548 liveuser 7
 
8
    This file is part of QBPWCF.
9
 
10
    QBPWCF is free software: you can redistribute it and/or modify
11
    it under the terms of the GNU General Public License as published by
12
    the Free Software Foundation, either version 3 of the License, or
13
    (at your option) any later version.
14
 
15
    QBPWCF is distributed in the hope that it will be useful,
16
    but WITHOUT ANY WARRANTY; without even the implied warranty of
17
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
    GNU General Public License for more details.
19
 
20
    You should have received a copy of the GNU General Public License
21
    along with QBPWCF.  If not, see <http://www.gnu.org/licenses/>.
22
 
23
*/
24
 
25
#使用 qbpwcf 命名空間
26
namespace qbpwcf;
27
 
28
#匯入套件
29
require_once("qbpwcf/allInOne.php");
30
 
31
#qbpwcf用的javascript
32
$qbpwcfJavaScript=javaScript::qbpwcfJavaScript();
33
 
34
#建議的log位置
35
$logFile=$_SERVER["DOCUMENT_ROOT"].$_SERVER["PHP_SELF"].".log";
36
 
37
#函式說明:
38
#使用 curl 來透過SMTP伺服器寄信
39
#回傳結果:
40
#$result["status"],寄信的情況,若爲"true",則十之八九沒有問題.
41
#$result["error"],錯誤訊息陣列
42
#$result["function"],當前執行的函數
43
#$result["warning"],警示訊息,一些不會導致失敗但不能說是完美的問題.
44
#$result["cmd"],寄信的指令.
45
#$result["detailCmd"],較詳細的寄信指令.
46
#必填參數:
47
#$conf["username"],字串,用來登入郵件伺服器的帳號
48
$conf["username"]="aesopowercms@gmail.com";
49
#$conf["password"],字串,用來登入郵件伺服器的密碼
50
$conf["password"]="gdmvelegbezyfcuf";
51
#$conf["receiverMail"],陣列,收件人的信箱
52
$conf["receiverMail"]=array("tcfxfzoi@gmail.com","tcfxfzoi+1@gmail.com");
53
#$conf["subject"],字串,郵件的主題
54
$conf["subject"]="test qbpwcf mail::curlSmtp function";
55
#$conf["plainBody"],字串,郵件本文的純文字內容.
56
$conf["plainBody"]="test qbpwcf mail::curlSmtp function";
57
#$conf["htmlBody"]="";,字串,郵件本文的html內容,多媒體盡量不要用base64的方式來嵌入,因為大部分的郵件服務(Gmail)都不支援,如果是在單機上的郵件軟體就可能有支援,例如:Evolution.
58
$conf["htmlBody"]="<div style=\"color:red\">test qbpwcf mail::curlSmtp function</div>";
59
#$conf["fileArgu"],字串,php內建變數「__FILE__」的內容.
60
$conf["fileArgu"]=__FILE__;
61
#可省略參數:
62
#$conf["mailServer"],字串,要使用的SMTP郵件伺服器網址與連接口,預設爲 smtps://smtp.gmail.com:465
63
#$conf["mailServer"]="";
64
#$conf["mailerMailDisplay"],字串,要顯示的寄件人信箱,預設爲 $conf["username"]
65
#$conf["mailerMailDisplay"]="";
66
#$conf["mailerNameDisplay"],字串,要顯示的寄件人姓名,預設爲 $conf["username"]
67
#$conf["mailerNameDisplay"]="";
68
#$conf["receiverMailDisplay"],陣列,要顯示的收件人信箱,預設爲 $conf["receiverMail"] 對應的元素.
69
#$conf["receiverMailDisplay"]="";#
70
#$conf["receiverNameDisplay"],陣列,要顯示的收件人姓名,預設爲 $conf["receiverMail"] 對應的元素.
71
#$conf["receiverNameDisplay"]="";
72
#$conf["attachment"],陣列,每個要寄送的附件路徑與檔案名稱
73
#$conf["attachment"]=array();
74
#$conf["attachmentName"],陣列,每個要寄送的附件顯示名稱,預設為$conf["attachment"]中的實際檔案名稱.
75
#$conf["attachmentName"]=array();
76
#$conf["attachmentMimeType"],陣列,每個附件的 mimeType,預設為"application/*".
77
#$conf["attachmentMimeType"]array();
78
#範例語句:
79
#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
80
#範例信件內容:
81
#From: "userName" <username@gmail.com>
82
#To: "receiverName" <userPassword@yahoo.com.tw>
83
#Subject: This is a test
84
#本文~
85
#參考資料:
86
#用curl來寄信=>http://stackoverflow.com/questions/14722556/using-curl-to-send-email
87
#降低安全性標準讓curl可以使用=>https://www.google.com/settings/security/lesssecureapps
88
#信件內容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/
89
#檔案每列不得超超過70個字元=>http://php.net/manual/en/function.mail.php
90
#寄信給多人=>https://github.com/curl/curl/issues/784
91
#備註:
92
#信件的內容格式有錯,導致本文無法顯示.
93
$curlSmtp=mail::curlSmtp($conf);
94
unset($conf);
95
 
96
#debug
97
var_dump($curlSmtp);
98
 
99
?>