From 7ef71e46c0ccd49d55e6e629f99e494bfda12877 Mon Sep 17 00:00:00 2001 From: gnuboard Date: Thu, 5 Sep 2013 16:58:48 +0900 Subject: [PATCH] =?UTF-8?q?PHPMailer=20=EB=A5=BC=20include=20=ED=95=98?= =?UTF-8?q?=EC=97=AC=20=EB=A9=94=EC=9D=BC=20=EB=B0=9C=EC=86=A1=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/mailer.lib.php | 72 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 59 insertions(+), 13 deletions(-) diff --git a/lib/mailer.lib.php b/lib/mailer.lib.php index 63d7c602e..c22a67b3f 100644 --- a/lib/mailer.lib.php +++ b/lib/mailer.lib.php @@ -1,6 +1,64 @@ IsSMTP(); // telling the class to use SMTP + $mail->Host = G4_SMTP; // SMTP server + } + $mail->From = $fmail; + $mail->FromName = $fname; + $mail->Subject = $subject; + $mail->AltBody = ""; // optional, comment out and test + $mail->MsgHTML($content); + $mail->AddAddress($to); + if ($cc) + $mail->AddCC($cc); + if ($bcc) + $mail->AddBCC($bcc); + //print_r2($file); exit; + if ($file != "") { + foreach ($file as $f) { + $mail->AddAttachment($f['path'], $f['name']); + } + } + return $mail->Send(); +} + +// 파일을 첨부함 +function attach_file($filename, $tmp_name) +{ + // 서버에 업로드 되는 파일은 확장자를 주지 않는다. (보안 취약점) + $dest_file = G4_DATA_PATH.'/tmp/'.str_replace('/', '_', $tmp_name); + move_uploaded_file($tmp_name, $dest_file); + /* + $fp = fopen($tmp_name, "r"); + $tmpfile = array( + "name" => $filename, + "tmp_name" => $tmp_name, + "data" => fread($fp, filesize($tmp_name))); + fclose($fp); + */ + $tmpfile = array("name" => $filename, "path" => $dest_file); + return $tmpfile; +} + +/* // 메일 보내기 (파일 여러개 첨부 가능) // type : text=0, html=1, text+html=2 function mailer($fname, $fmail, $to, $subject, $content, $type=0, $file="", $cc="", $bcc="") @@ -78,24 +136,11 @@ function mailer($fname, $fmail, $to, $subject, $content, $type=0, $file="", $cc= } // 파일 첨부시 -/* $fp = fopen(__FILE__, "r"); $file[] = array( "name"=>basename(__FILE__), "data"=>fread($fp, filesize(__FILE__))); fclose($fp); -*/ - -// 파일을 첨부함 -function attach_file($filename, $file) -{ - $fp = fopen($file, "r"); - $tmpfile = array( - "name" => $filename, - "data" => fread($fp, filesize($file))); - fclose($fp); - return $tmpfile; -} // 메일 유효성 검사 // core PHP Programming 책 참고 @@ -360,4 +405,5 @@ function get_boundary_msg() { $three = strtoupper(substr(strrev($uniqchr),0,8)); return "----=_NextPart_000_000${one}_${two}.${three}"; } +*/ ?> \ No newline at end of file