Subversion Repositories php-qbpwcf

Rev

Rev 81 | Rev 226 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 liveuser 1
<?php
2
 
3
/*
4
 
5
        QBPWCF, Quick Build PHP website Component base on Fedora Linux.
6
    Copyright (C) 2015~2024 Min-Jhin,Chen
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
$output=array();
30
 
31
#取得 lib path
98 liveuser 32
exec("php -f ".escapeshellarg(pathinfo(__FILE__)["dirname"]."/../../../../usr/bin/libexec/folderOfUsrLib.php"),$output,$status);
1 liveuser 33
 
34
#如果執行失敗
35
if($status!==0){
36
 
37
	#debug
38
	var_dump(__LINE__,$output);
39
 
40
	#結束執行,回傳shell 1.
41
	exit(1);
42
 
43
	}#if end
44
 
45
#儲存lib path
46
$folderOfUsrLib=$output[0];
47
 
48
#初始化輸出
49
$output=array();
50
 
51
#以該檔案的實際位置的 lib path 為 include path 首位
98 liveuser 52
exec("cd ".pathinfo(__FILE__)["dirname"]."/../../../../usr/".$folderOfUsrLib."/qbpwcf;pwd;",$output,$status);
1 liveuser 53
set_include_path($output[0].PATH_SEPARATOR.get_include_path());
54
 
55
#匯入套件
56
require_once("allInOne.php");
57
 
58
#qbpwcf用的javascript
59
$qbpwcfJavaScript=javaScript::qbpwcfJavaScript();
60
 
61
#建議的log位置
62
$logFile=$_SERVER["DOCUMENT_ROOT"].$_SERVER["PHP_SELF"].".log";
63
 
64
#函式說明:
65
#使用 curl 來透過SMTP伺服器寄信
66
#回傳結果:
67
#$result["status"],寄信的情況,若爲"true",則十之八九沒有問題.
68
#$result["error"],錯誤訊息陣列
69
#$result["function"],當前執行的函數
70
#$result["warning"],警示訊息,一些不會導致失敗但不能說是完美的問題.
71
#$result["cmd"],寄信的指令.
72
#$result["detailCmd"],較詳細的寄信指令.
73
#必填參數:
74
#$conf["username"],字串,用來登入郵件伺服器的帳號
47 liveuser 75
$conf["username"]=systemMailAcct;
1 liveuser 76
#$conf["password"],字串,用來登入郵件伺服器的密碼
47 liveuser 77
$conf["password"]=systemMailPass;
1 liveuser 78
#$conf["receiverMail"],陣列,收件人的信箱
79
$conf["receiverMail"]=array("tcfxfzoi@gmail.com","tcfxfzoi+1@gmail.com");
80
#$conf["subject"],字串,郵件的主題
81
$conf["subject"]="test qbpwcf mail::curlSmtp function";
82
#$conf["plainBody"],字串,郵件本文的純文字內容.
83
$conf["plainBody"]="test qbpwcf mail::curlSmtp function";
84
#$conf["htmlBody"]="";,字串,郵件本文的html內容,多媒體盡量不要用base64的方式來嵌入,因為大部分的郵件服務(Gmail)都不支援,如果是在單機上的郵件軟體就可能有支援,例如:Evolution.
85
$conf["htmlBody"]="<div style=\"color:red\">test qbpwcf mail::curlSmtp function</div>";
86
#$conf["fileArgu"],字串,php內建變數「__FILE__」的內容.
87
$conf["fileArgu"]=__FILE__;
88
#可省略參數:
89
#$conf["mailServer"],字串,要使用的SMTP郵件伺服器網址與連接口,預設爲 smtps://smtp.gmail.com:465
90
#$conf["mailServer"]="";
91
#$conf["mailerMailDisplay"],字串,要顯示的寄件人信箱,預設爲 $conf["username"]
92
#$conf["mailerMailDisplay"]="";
93
#$conf["mailerNameDisplay"],字串,要顯示的寄件人姓名,預設爲 $conf["username"]
94
#$conf["mailerNameDisplay"]="";
95
#$conf["receiverMailDisplay"],陣列,要顯示的收件人信箱,預設爲 $conf["receiverMail"] 對應的元素.
96
#$conf["receiverMailDisplay"]="";#
97
#$conf["receiverNameDisplay"],陣列,要顯示的收件人姓名,預設爲 $conf["receiverMail"] 對應的元素.
98
#$conf["receiverNameDisplay"]="";
99
#$conf["attachment"],陣列,每個要寄送的附件路徑與檔案名稱
100
#$conf["attachment"]=array();
101
#$conf["attachmentName"],陣列,每個要寄送的附件顯示名稱,預設為$conf["attachment"]中的實際檔案名稱.
102
#$conf["attachmentName"]=array();
103
#$conf["attachmentMimeType"],陣列,每個附件的 mimeType,預設為"application/*".
104
#$conf["attachmentMimeType"]array();
105
#範例語句:
106
#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
107
#範例信件內容:
108
#From: "userName" <username@gmail.com>
109
#To: "receiverName" <userPassword@yahoo.com.tw>
110
#Subject: This is a test
111
#本文~
112
#參考資料:
113
#用curl來寄信=>http://stackoverflow.com/questions/14722556/using-curl-to-send-email
114
#降低安全性標準讓curl可以使用=>https://www.google.com/settings/security/lesssecureapps
115
#信件內容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/
116
#檔案每列不得超超過70個字元=>http://php.net/manual/en/function.mail.php
117
#寄信給多人=>https://github.com/curl/curl/issues/784
118
#備註:
119
#信件的內容格式有錯,導致本文無法顯示.
120
$curlSmtp=mail::curlSmtp($conf);
121
unset($conf);
122
 
123
#debug
124
var_dump($curlSmtp);
125
 
126
?>