136 lines
4.3 KiB
PHP
136 lines
4.3 KiB
PHP
<?php
|
|
if (!defined('_GNUBOARD_')) exit;
|
|
|
|
include_once(G5_PHPMAILER_PATH.'/PHPMailerAutoload.php');
|
|
|
|
// 메일 보내기 (파일 여러개 첨부 가능)
|
|
// type : text=0, html=1, text+html=2
|
|
/* 원본 이메일 발송 기능
|
|
function mailer($fname, $fmail, $to, $subject, $content, $type=0, $file="", $cc="", $bcc="")
|
|
{
|
|
global $config;
|
|
global $g5;
|
|
|
|
// 메일발송 사용을 하지 않는다면
|
|
if (!$config['cf_email_use']) return;
|
|
|
|
if ($type != 1)
|
|
$content = nl2br($content);
|
|
|
|
$result = run_replace('mailer', $fname, $fmail, $to, $subject, $content, $type, $file, $cc, $bcc);
|
|
|
|
if( is_array($result) && isset($result['return']) ){
|
|
return $result['return'];
|
|
}
|
|
|
|
$mail_send_result = false;
|
|
|
|
try {
|
|
$mail = new PHPMailer(); // defaults to using php "mail()"
|
|
if (defined('G5_SMTP') && G5_SMTP) {
|
|
$mail->IsSMTP(); // telling the class to use SMTP
|
|
$mail->Host = G5_SMTP; // SMTP server
|
|
if(defined('G5_SMTP_PORT') && G5_SMTP_PORT)
|
|
$mail->Port = G5_SMTP_PORT;
|
|
}
|
|
$mail->CharSet = 'UTF-8';
|
|
$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']);
|
|
}
|
|
}
|
|
|
|
$mail = run_replace('mail_options', $mail, $fname, $fmail, $to, $subject, $content, $type, $file, $cc, $bcc);
|
|
|
|
if (!($mail_send_result = $mail->send())) {
|
|
throw new Exception($mail->ErrorInfo);
|
|
}
|
|
|
|
} catch (Exception $e) {
|
|
error_log("Mail sending error: " . $e->getMessage());
|
|
}
|
|
|
|
run_event('mail_send_result', $mail_send_result, $mail, $to, $cc, $bcc);
|
|
|
|
return $mail_send_result;
|
|
}
|
|
*/
|
|
|
|
function mailer($fname, $fmail, $to, $subject, $content, $type=0, $file="", $cc="", $bcc="")
|
|
{
|
|
|
|
global $config;
|
|
global $g5;
|
|
|
|
// 메일발송 사용을 하지 않는다면
|
|
if (!$config['cf_email_use']) return;
|
|
|
|
if ($type != 1)
|
|
|
|
$content = nl2br($content);
|
|
$mail = new PHPMailer(); // defaults to using php “mail()”
|
|
|
|
if (defined('G5_SMTP') && G5_SMTP) {
|
|
|
|
// Modified By taeho. 2015.12.31, 메일을 보낼 때 메일서버에 접속하기 위한 설정입니다.
|
|
$mail->IsSMTP();
|
|
$mail->SMTPAuth = true; // enable SMTP authentication
|
|
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
|
|
$mail->Host = "smtp.daum.net"; // sets GMAIL as the SMTP server
|
|
$mail->Port = 465; // set the SMTP port for the GMAIL server
|
|
$mail->Username = "first_garden@daum.net"; // MAIL username
|
|
$mail->Password = "rsdkjqeaxzdtsfrx"; // MAIL password
|
|
|
|
}
|
|
|
|
// 아래 두개를 설정하지 않으면 한글 깨짐
|
|
$mail->CharSet = 'UTF-8'; // 문자셋 설정
|
|
$mail->Encoding = 'base64'; // 인코딩 설정
|
|
$mail->isHTML(true); // HTML 메일 명시
|
|
$mail->AddAddress($to);
|
|
// $mail->AddAddress($to); // 중복 제거
|
|
|
|
|
|
$mail->From = 'firstgarden@firstgarden.co.kr'; // 사용자에게 보여줄 보내는이 메일주소
|
|
$mail->FromName = '퍼스트가든'; // 사용자에게 보여줄 보내는 사람의 이름 등
|
|
$mail->Subject = $subject;
|
|
$mail->AltBody = ''; // optional, comment out and test
|
|
$mail->MsgHTML($content);
|
|
$mail->AddAddress($to);
|
|
$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 = G5_DATA_PATH.'/tmp/'.str_replace('/', '_', $tmp_name);
|
|
move_uploaded_file($tmp_name, $dest_file);
|
|
$tmpfile = array("name" => $filename, "path" => $dest_file);
|
|
return $tmpfile;
|
|
} |