source: hadoop-register/smtp_mail.php

Last change on this file was 85, checked in by wade, 15 years ago
  • 2009-06-23 修正認證信連結會重複給予帳號密碼。
  • 2009-06-23 主機位址格式為 htt://位址,後面不必再加 /
File size: 2.5 KB
Line 
1<?php
2
3error_reporting(E_STRICT);
4
5date_default_timezone_set('America/Toronto');
6
7// 載入 init.php
8require_once ("./etc/init.php");
9include_once ("./etc/phpMailer/class.phpmailer.php");
10
11$mail             = new PHPMailer();
12
13// 由 operator 判斷需要寄出什麼信件
14switch ($my_user->operator)
15{
16  // 寄送認證信
17  case "identification":                   
18    // 讀出認證信範本
19    // $body = $mail->getFile('content_identification.html');
20    // 讀出認證信內容
21    $body = $body . $my_user->get_activate_mailbody();
22    $body = eregi_replace("[\]",'',$body);
23    break;
24  // 寄送密碼信
25  case "new_password":
26        // 讀出密碼信內容
27        $body = $body . $my_user->get_new_password_mailbody();
28        $body = eregi_replace("[\]",'',$body);
29    break;
30  // 寄送 hadoop 帳號密碼信
31  case "hadoop_user_password":
32        // 讀出 hadoop 帳號密碼信內容
33        $body = $body . $my_user->get_hadoop_user_password_mailbody();
34        $body = eregi_replace("[\]",'',$body);
35        break; 
36}
37
38
39$mail->IsSMTP();
40$mail->SMTPAuth   = true;                  // enable SMTP authentication
41$mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
42$mail->Host       = $mail_server_host;     // sets GMAIL as the SMTP server
43$mail->Port       = 465;                   // set the SMTP port for the GMAIL server
44
45$mail->Username   = $mail_user;            // GMAIL username
46$mail->Password   = $mail_password;      // GMAIL password
47
48$mail->AddReplyTo($mail_account , $mail_account_name);
49
50$mail->From       = $mail_account;
51$mail->FromName   = $mail_account_name;
52
53$mail->Subject    = "Hadoop 帳號系統信";
54
55$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
56$mail->WordWrap   = 50; // set word wrap
57
58$mail->CharSet="utf-8";                                   // 設定e-mail編碼
59 
60$mail->Encoding = "base64";                               // 設定信件編碼
61
62$mail->MsgHTML($body);
63
64$mail->AddAddress($my_user->email, "");                 // 寄件地址,顯示名稱
65
66$mail->AddAttachment("images/phpmailer.gif");             // attachment
67
68$mail->IsHTML(true); // send as HTML
69
70if(!$mail->Send()) {
71  $message = "Mailer Error: " . $mail->ErrorInfo;
72  echo "<BR>" . $message;
73    // $my_user->redirect_to("$w_localhost", $message);
74} else {
75    // $message = "Message sent!";
76    // $my_user->redirect_to("$w_localhost", $error_message);
77}
78
79?>
Note: See TracBrowser for help on using the repository browser.