테스트 사이트 - 개발 중인 베타 버전입니다

write_update와 mailer 파일로 메일 전송 채택완료

noobmaster 5년 전 조회 3,832

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

 

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

</p>

<p>//write_update.php</p>

<p><?php

if (!($w == 'u' || $w == 'cu') && $config['cf_email_use'] && $board['bo_use_email']) {</p>

<p>    // 관리자의 정보를 얻고

    $super_admin = get_admin('super');

    $group_admin = get_admin('group');

    $board_admin = get_admin('board');</p>

<p>    $wr_subject = get_text(stripslashes($wr_subject));</p>

<p>    $tmp_html = 0;

    if (strstr($html, 'html1'))

        $tmp_html = 1;

    else if (strstr($html, 'html2'))

        $tmp_html = 2;</p>

<p>    $wr_content = conv_content(conv_unescape_nl(stripslashes($wr_content)), $tmp_html);</p>

<p>    $warr = array( ''=>'입력', 'u'=>'수정', 'r'=>'답변', 'c'=>'코멘트', 'cu'=>'코멘트 수정' );

    $str = $warr[$w];</p>

<p>    

    $subject = '[000] 새 문의가 등록되었습니다.';</p>

<p>

    $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);

    </p>

<p>    for ($i=0; $i<count($unique_email); $i++) {

        mailer($wr_name, $wr_email, $unique_email[$i], $subject, $content, 1);

    }

}

?></p>

<p>

 

</p>

<p>//mailer.lib</p>

<p><?php

if (!defined('_GNUBOARD_')) exit;</p>

<p>include_once(G5_PHPMAILER_PATH.'/PHPMailerAutoload.php');</p>

<p>//문의 작성 시 관리자에게 전송되는 메일

// 메일 보내기 (파일 여러개 첨부 가능)

// type : text=0, html=1, text+html=2

function mailer($fname, $fmail, $to, $subject, $content, $type=0, $file="", $cc="", $bcc="")

{

    global $config;

    global $g5;</p>

<p>    // 메일발송 사용을 하지 않는다면

    if (!$config['cf_email_use']) return;</p>

<p>    if ($type != 1)

        $content = nl2br($content);</p>

<p>    $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();

}</p>

<p>// 파일을 첨부함

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;

}

?></p>

<p>

 

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

댓글을 작성하려면 로그인이 필요합니다.

답변 1개

채택된 답변
+20 포인트

메일에 파일을 직접 첨부하는 방법보다는 파일의 링크를 첨부하는것이 좋을듯합니다.

 

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인