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

게시판 글 작성 시 메일 발송 채택완료

rain99 4년 전 조회 1,720

카페24 윈도우 가상서버 호스팅 사용중에 있는데요. 게시판 글 작성 시 이동 하는 write_update.skin.php 추가 했는데오 메일 발송이 안되어서요. mailer.lib.php 아래 방법으로도 해봤는데 발송이 안와서요ㅜㅜ

혹시 방법 이있을까요?

 

mailer.lib.php 

</strong></p>

<p><strong><?php

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

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

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

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

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

{

    global $config;

    global $g5;</strong></p>

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

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

<p><strong>    if ($type != 1)

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

<p><strong>    $result = run_replace('mailer', $fname, $fmail, $to, $subject, $content, $type, $file, $cc, $bcc);

    

    if( is_array($result) && isset($result['return']) ){

        return $result['return'];

    }</strong></p>

<p><strong>    $mail_send_result = false;</strong></p>

<p><strong>    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;

            여기까지 */</strong></p>

<p><strong>            $mail->IsSMTP(); // telling the class to use SMTP

            $mail->SMTPSecure = "ssl";

            $mail->SMTPAuth = true;

            $mail->Host = 'smtp.naver.com'; // SMTP server

            $mail->Port = 465;            

            $mail->Username = '네이버아이디';

            $mail->Password = '네이버비밀번호';        

        }

        $mail->CharSet = 'UTF-8';

        /* 이부분은 환경설정 > 관리자이메일 과 달라야한다면 입력해주시면되고

        그렇지않다면 그냥 두시면됩니다 */

        $mail->From = "보내는이의메일주소(Username 과 달라도됩니다)";

        $mail->FromName = "보내는이이름";        

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

            }

        }</strong></p>

<p><strong>        $mail = run_replace('mail_options', $mail, $fname, $fmail, $to, $subject, $content, $type, $file, $cc, $bcc);</strong></p>

<p><strong>        $mail_send_result = $mail->send();</strong></p>

<p><strong>    } catch (Exception $e) {

    }</strong></p>

<p><strong>    run_event('mail_send_result', $mail_send_result, $mail, $to, $cc, $bcc);</strong></p>

<p><strong>    return $mail_send_result;

}</strong></p>

<p><strong>// 파일을 첨부함

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;

}</strong></p>

<p><strong>
 

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

답변 2개

채택된 답변
+20 포인트
4년 전
mailer(보낸사람이름, 보낸사람메일, 받을사람, 제목, 내용.., 메일타입, 파일변수, 참조1, 참조2)
이런식으로 변수 넣으셔야합니다.

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

소스만 봐서는 호출하는부분이 없네요.

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

답변에 대한 댓글 1개

r
rain99
4년 전
해결 했어요!! 감사합니다~^^

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

4년 전

저렇게만 하시면 안되고 function 을 호출하셔야 합니다.

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

답변에 대한 댓글 1개

r
rain99
4년 전
답변 감사합니다! function 호출을 어떤식으로 하면 될까요? 제가 초보여서요ㅜㅜ 예시라도 알려주실 수 있을까요?ㅠㅠ

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

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

로그인