[57] | 1 | <?php |
---|
| 2 | |
---|
| 3 | error_reporting(E_STRICT); |
---|
| 4 | |
---|
| 5 | date_default_timezone_set('America/Toronto'); |
---|
| 6 | |
---|
| 7 | // 載入 init.php |
---|
| 8 | require_once ("./etc/init.php"); |
---|
| 9 | include_once ("./etc/phpMailer/class.phpmailer.php"); |
---|
| 10 | |
---|
| 11 | $mail = new PHPMailer(); |
---|
| 12 | |
---|
| 13 | // 由 operator 判斷需要寄出什麼信件 |
---|
| 14 | switch ($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 | |
---|
| 70 | if(!$mail->Send()) { |
---|
| 71 | $message = "Mailer Error: " . $mail->ErrorInfo; |
---|
| 72 | echo "<BR>" . $message; |
---|
[85] | 73 | // $my_user->redirect_to("$w_localhost", $message); |
---|
[57] | 74 | } else { |
---|
| 75 | // $message = "Message sent!"; |
---|
[85] | 76 | // $my_user->redirect_to("$w_localhost", $error_message); |
---|
[57] | 77 | } |
---|
| 78 | |
---|
| 79 | ?> |
---|