메일 전송이 갑자기 안됩니다

메일 전송이 갑자기 안됩니다

QA

메일 전송이 갑자기 안됩니다

본문

펜션시스템 이용중 예약하면 메일전송이 되게 해두었습니다.

 

그런데 잘되던게 어제 오후 부터 예약을해도 전송이 되지않기 시작했습니다.

 

개발소스는 건드리지 않았고, adm페이지 조차건드리지 않았는데 갑자기 전송이안되니 당황스럽습니다.

 

adm페이지에있는 테스트 메일전송도 해보았으나 갑자기 전송이 되지않습니다.

 

늘받던 이메일이아닌 다른이메일 여러개도 시도해보았지만 전부 전송 되지않았습니다.

 

혹시몰라 소스코드 남겨봅니다.

 

white_update.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($wr_content), $tmp_html);

    $warr = array( ''=>'입력', 'u'=>'수정', 'r'=>'답변', 'c'=>'코멘트', 'cu'=>'코멘트 수정' );
    $str = $warr[$w];

    $subject = '['.$config['cf_title'].'] '.$board['bo_subject'].' 게시판에 '.$str.'글이 올라왔습니다.';

    $link_url = G5_BBS_URL.'/board.php?bo_table='.$bo_table.'&wr_id='.$wr_id.'&'.$qstr;

    include_once(G5_LIB_PATH.'/mailer.lib.php');

    ob_start();
    include_once ('./write_update_mail.php');
    $content = ob_get_contents();
    ob_end_clean();

    $array_email = array();
    // 게시판관리자에게 보내는 메일
    if ($config['cf_email_wr_board_admin']) $array_email[] = $board_admin['mb_email'];
    // 게시판그룹관리자에게 보내는 메일
    if ($config['cf_email_wr_group_admin']) $array_email[] = $group_admin['mb_email'];
    // 최고관리자에게 보내는 메일
    if ($config['cf_email_wr_super_admin']) $array_email[] = $super_admin['mb_email'];

    // 원글게시자에게 보내는 메일
    if ($config['cf_email_wr_write']) {
        if($w == '')
            $wr['wr_email'] = $wr_email;

        $array_email[] = $wr['wr_email'];
    }

    // 옵션에 메일받기가 체크되어 있고, 게시자의 메일이 있다면
    if (strstr($wr['wr_option'], 'mail') && $wr['wr_email'])
        $array_email[] = $wr['wr_email'];

    // 중복된 메일 주소는 제거
    $unique_email = array_unique($array_email);
    $unique_email = array_values($unique_email);
    for ($i=0; $i<count($unique_email); $i++) {
        mailer($wr_name, $wr_email, $unique_email[$i], $subject, $content, 1);
    }
}

 

 

mailer.lib.php

 

include_once(G5_PHPMAILER_PATH.'/class.phpmailer.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
    }
    $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();
}

 

 

config.php

define('G5_PHPMAILER_DIR',  'PHPMailer_v2.0.4');

 

 

class.phpmailer.php

 function Send() {
    $header = '';
    $body = '';
    $result = true;

    if((count($this->to) + count($this->cc) + count($this->bcc)) < 1) {
      $this->SetError($this->Lang('provide_address'));
      return false;
    }

    /* Set whether the message is multipart/alternative */
    if(!empty($this->AltBody)) {
      $this->ContentType = 'multipart/alternative';
    }

    $this->error_count = 0; // reset errors
    $this->SetMessageType();
    $header .= $this->CreateHeader();
    $body = $this->CreateBody();

    if($body == '') {
      return false;
    }

    /* Choose the mailer */
    switch($this->Mailer) {
      case 'sendmail':
        $result = $this->SendmailSend($header, $body);
        break;
      case 'smtp':
        $result = $this->SmtpSend($header, $body);
        break;
      case 'mail':
        $result = $this->MailSend($header, $body);
        break;
      default:
        $result = $this->MailSend($header, $body);
        break;
        //$this->SetError($this->Mailer . $this->Lang('mailer_not_supported'));
        //$result = false;
        //break;
    }

    return $result;
  }

 

혹시 더 필요한 소스 있으면 올리겠습니다 

 

3731834642_1599805645.1767.png

 

 

이 질문에 댓글 쓰기 :

답변 3

메일로그에 왜 메일이 실패되었는지 이유가 기록됩니다.

 

따라서 메일전송이 실패하면, 제일 먼저 메일로그를 확인해서,

 

실패원인이 무엇인가 찾아야 합니다.

 

리눅스 서버이면 보통 /var/log/maillog 경로에 로그가 남습니다.

웹호스팅이면 메일로그는 볼수 있는 권한이 없어서 메일로그를 볼수 없습니다.

메일이 안나가는 부분은 혹시 웹호스팅이라면 웹호스팅사에 문의를 해보셔야 할듯 합니다.

sendmail 발송되는 문제가 있을수 있고 광고성으로 오인해서 안나갈수도 있기 때문에 화이트 도메인이 정상적으로 등록이 된건지도 체크해 보셔야 할듯 합니다.

받는 메일 회사(네이버나 다음등) 고객센터에도 해당 도메인이 스팸으로 등록되어 있는지 문의해보세요.

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

회원로그인

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