write_update와 mailer 파일로 메일 전송

write_update와 mailer 파일로 메일 전송

QA

write_update와 mailer 파일로 메일 전송

본문

그누보드에 내장된 mailer.php파일과 wirte_update.php파일만으로 새글 알림메일 전송시 첨부파일까지 전송되게는 못하나요?

 

사용중인 코드는 아래와 같습니당


//write_update.php
<?php
if (!($w == 'u' || $w == 'cu') && $config['cf_email_use'] && $board['bo_use_email']) {
    // 관리자의 정보를 얻고
    $super_admin = get_admin('super');
    $group_admin = get_admin('group');
    $board_admin = get_admin('board');
    $wr_subject = get_text(stripslashes($wr_subject));
    $tmp_html = 0;
    if (strstr($html, 'html1'))
        $tmp_html = 1;
    else if (strstr($html, 'html2'))
        $tmp_html = 2;
    $wr_content = conv_content(conv_unescape_nl(stripslashes($wr_content)), $tmp_html);
    $warr = array( ''=>'입력', 'u'=>'수정', 'r'=>'답변', 'c'=>'코멘트', 'cu'=>'코멘트 수정' );
    $str = $warr[$w];
    
    $subject = '[000] 새 문의가 등록되었습니다.';

    $link_url = get_pretty_url($bo_table, $wr_id, $qstr);
    
    include(G5_LIB_PATH.'/mailer_admin.lib.php');
    
    ob_start();
    include_once ('./write_update_mail_admin.php');
    $content = ob_get_contents();
    ob_end_clean();
    
    $array_email = array();
    
    // 최고관리자에게 보내는 메일
    if ($config['cf_email_wr_super_admin']) $array_email[] = $super_admin['mb_email'];
    
    // 중복된 메일 주소는 제거
    $unique_email = array_unique($array_email);
    $unique_email = run_replace('write_update_mail_list', array_values($unique_email), $board, $wr_id);
    
    for ($i=0; $i<count($unique_email); $i++) {
        mailer($wr_name, $wr_email, $unique_email[$i], $subject, $content, 1);
    }
}
?>

 


//mailer.lib
<?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);
    $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 = 'RIGAS';
    $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 = G5_DATA_PATH.'/tmp/'.str_replace('/', '_', $tmp_name);
    move_uploaded_file($tmp_name, $dest_file);
    $tmpfile = array("name" => $filename, "path" => $dest_file);
    return $tmpfile;
}
?>

 

주석에는 파일첨부가 가능하다는데 아무리 찾아봐도 방법이 보이질 않습니다..도와주세요..

이 질문에 댓글 쓰기 :

답변 1

답변을 작성하시기 전에 로그인 해주세요.
전체 123,653
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT