2026, 새로운 도약을 시작합니다.

PHPMailer 질문합니다. 채택완료

다음 스마트워크를 이용해서 그누보드5의 각종 이메일 기능을 사용하려고 하는데요, 애저 웹 앱에서 잘 작동하던 것을 확인한 설정파일을 그대로 제 컴퓨터 서버에 올렸더니 서버에 연결할 수 없다는 오류 메시지가 뜹니다.

윈도 방화벽과 공유기 포트포워드는 TCP 25, 465, 587, 993, 995 포트에 대해 양방향 모두 개방하였습니다.

왜 안되는걸까요?

아래는 다음에서 제시한 연결 방법입니다.

3543798352_1575609173.573.png

아래는 mailer.lib.php의 mailer 함수 부분의 코드입니다.

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

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

function mailer($fname, $fmail, $to, $subject, $content, $type=2, $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->IsSMTP();

    $mail->SMTPDebug = 4;

    $mail->SMTPSecure = "ssl";

    $mail->SMTPAuth = true;

    $mail->Host = "smtp.daum.net";

    $mail->Port = 465;

    $mail->Username = "다음 아이디";

    $mail->Password = "카카오계정 비밀번호";

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

    $mail->From = "pdmnu@pdmnu.com";

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

        }

    }

    return $mail->send();

}

위와 같이 입력하였더니 발송 테스트에서 아래와 같은 오류 메시지가 출력되었습니다.

Copy
2019-12-06 05:08:13 Connection: opening to ssl://smtp.daum.net:465, timeout=300, options=array ( )

2019-12-06 05:08:13 Connection: Failed to connect to server. Error number 2. "Error notice: stream_socket_client() [function.stream-socket-client]: SSL operation failed with code 1. OpenSSL Error messages: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed

2019-12-06 05:08:13 Connection: Failed to connect to server. Error number 2. "Error notice: stream_socket_client() [function.stream-socket-client]: Failed to enable crypto

2019-12-06 05:08:13 Connection: Failed to connect to server. Error number 2. "Error notice: stream_socket_client() [function.stream-socket-client]: unable to connect to ssl://smtp.daum.net:465 (Unknown error)

2019-12-06 05:08:13 SMTP ERROR: Failed to connect to server: (0)

2019-12-06 05:08:13 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

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

로그인
🐛 버그신고