diff --git a/bbs/formmail_send.php b/bbs/formmail_send.php index 635f4aca6..3d43aebae 100644 --- a/bbs/formmail_send.php +++ b/bbs/formmail_send.php @@ -9,6 +9,13 @@ if (!$config['cf_email_use']) if (!$is_member && $config['cf_formmail_is_member']) alert_close('회원만 이용하실 수 있습니다.'); +// 발송 횟수 제한 (직접 POST 우회 방지) +$sendmail_count = (int)get_session('ss_sendmail_count') + 1; +set_session('ss_sendmail_count', $sendmail_count); +if ($sendmail_count > 3) { + alert_close('폼메일 발송 횟수를 초과하였습니다.'); +} + $email_enc = new str_encrypt(); $to = $email_enc->decrypt($to); @@ -40,13 +47,23 @@ if ($type) { else $mail_content = $content; -// 환경설정에서 폼메일 사용 여부가 회원만 사용에 체크되어 있으면 -if ($config['cf_formmail_is_member']) { +// 발신자 정보 서버측 강제 설정 +$reply_to_email = ''; +if ($is_member) { $fnick = (isset($member['mb_nick']) && $member['mb_nick']) ? $member['mb_nick'] : $member['mb_name']; $fmail = $member['mb_email']; +} else { + // 비회원: From을 관리자 이메일로 고정 (발신자 위장 방지) + // 비회원이 입력한 이메일은 Reply-To로 설정하여 회신 기능 유지 + $user_email = get_email_address(trim($fmail)); + $fnick = strip_tags(trim($fnick)); + $fmail = $config['cf_admin_email']; + if ($user_email) { + $reply_to_email = $user_email; + } } -mailer($fnick, $fmail, $to, $subject, $mail_content, $type, $file); +mailer($fnick, $fmail, $to, $subject, $mail_content, $type, $file, '', '', $reply_to_email); // 임시 첨부파일 삭제 if(!empty($file)) { diff --git a/lib/mailer.lib.php b/lib/mailer.lib.php index 0fc77de7c..eba5d5cb5 100644 --- a/lib/mailer.lib.php +++ b/lib/mailer.lib.php @@ -5,7 +5,7 @@ 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="") +function mailer($fname, $fmail, $to, $subject, $content, $type=0, $file="", $cc="", $bcc="", $reply_to="") { global $config; global $g5; @@ -43,6 +43,8 @@ function mailer($fname, $fmail, $to, $subject, $content, $type=0, $file="", $cc= $mail->addCC($cc); if ($bcc) $mail->addBCC($bcc); + if ($reply_to) + $mail->addReplyTo($reply_to); //print_r2($file); exit; if ($file != "") { foreach ($file as $f) {