-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmailing_config.php
executable file
·69 lines (56 loc) · 2.14 KB
/
mailing_config.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
include("PHPMailer-master/class.phpmailer.php"); //匯入PHPMailer類別
function mail_config($mail)
{
$mail->IsSMTP(); //設定使用SMTP方式寄信
$mail->SMTPAuth = true; //設定SMTP需要驗證
$mail->SMTPSecure = "ssl"; //Gmail的SMTP主機需要使用SSL連線
$mail->Host = "smtp.gmail.com"; //Gamil的SMTP主機
$mail->Port = 465; //Gamil的SMTP主機的SMTP埠位為465埠。
$mail->CharSet = "big5"; //設定郵件編碼
$mail->Username = "fbukevin"; //設定驗證帳號
$mail->Password = "simple life"; //設定驗證密碼
$mail->From = "[email protected]"; //設定寄件者信箱 (之後應該開一個專用或是改用臉書社團的mail?)
$mail->FromName = "CCUMISKM"; //設定寄件者姓名
}
function send_passwd($dest, $receiver, $password)
{
$mail= new PHPMailer(); //建立新物件
mail_config($mail);
$mail->Subject = "Password Information"; //設定郵件標題
$mail->Body = "Hello, ".$receiver."! 你已經啟用了 中正資管知識加值系統 (CCUMISKM)<br>您首次登入的密碼為 : ".$password; //設定郵件內容
$mail->IsHTML(true); //設定郵件內容為HTML
$mail->AddAddress($dest, $reciever); //設定收件者郵件及名稱
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
/*TODO: 以後這裡應該要開一個 Log 檔*/
return false;
}
else
{
echo "Message sent!";
return true;
}
}//end_of_function
function lost_passwd($dest, $reciever, $password)
{
$mail= new PHPMailer();
mail_config($mail);
$mail->Subject = "Password Query";
$mail->Body = "Hello, $reciever! 你的密碼是:$password";
$mail->IsHTML(true);
$mail->AddAddress($dest, $reciever);
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
/*TODO: 以後這裡應該要開一個 Log 檔*/
return false;
}
else
{
echo "Message sent!";
return true;
}
}//end_of_function
?>