본문 바로가기
기록

그누보드 SMTP Mailer() 커스텀 사용하기

by 디스코비스킷 2021. 10. 5.
반응형

formmail.php를 활용하여

게스트도 회원정보없이 쓸 수있게끔 guest_formmail.php를 만들었다.

fommail에 관련한 파일은

bbs/formmail.php

bbs/formmail_send.php

skin/member/basic/formmail.skin.php

skin/member/basic/style.css (에서 formmail부분)

 

guest_formmail.php

<?php
include_once('./_common.php');
include_once(G5_CAPTCHA_PATH.'/captcha.lib.php');
include_once('./_head.php');
$sendmail_count = (int)get_session('ss_sendmail_count') + 1;
if ($sendmail_count > 3)
alert_close('한번 접속후 일정수의 메일만 발송할 수 있습니다.\\n\\n계속해서 메일을 보내시려면 다시 로그인 또는 접속하여 주십시오.');
$g5['title'] = '메일 쓰기';
include_once(G5_PATH.'/head.sub.php');
if (!isset($type))
$type = 0;
$type_checked[0] = $type_checked[1] = $type_checked[2] = "";
$type_checked[$type] = 'checked';
include_once($member_skin_path.'/guest_formmail.skin.php');
include_once('./_tail.php');
include_once(G5_PATH.'/tail.sub.php');
?>

$name, $email은 창띄울때 url로 가져가는 값이라 지우고, type부분도 삭제해도된다 나는 심플하게 쓸 거니까

 

 

guest_formmail_send.php

<?php
include_once('./_common.php');
include_once(G5_CAPTCHA_PATH.'/captcha.lib.php');
include_once(G5_LIB_PATH.'/mailer.lib.php');
if (!preg_match("/([0-9a-zA-Z_-]+)@([0-9a-zA-Z_-]+)\.([0-9a-zA-Z_-]+)/", $to)){
alert_close('이메일 주소가 형식에 맞지 않아서, 메일을 보낼수 없습니다.');
}
$content = stripslashes($content);
if ($type == 2) {
$type = 1;
$content = str_replace("\n", "<br>", $content);
}
// html 이면
if ($type) {
$current_url = G5_URL;
$mail_content = '<!doctype html><html lang="ko"><head><meta charset="utf-8"><title>메일보내기</title><link rel="stylesheet" href="'.$current_url.'/style.css"></head><body>'.$content.'</body></html>';
}
else
$mail_content = $content;
mailer($fnick, $fmail, $to, $subject, $mail_content, $type, $file);
//$html_title = $tmp_to . "님께 메일발송";
$html_title = '메일 발송중';
include_once(G5_PATH.'/head.sub.php');
alert('메일을 정상적으로 발송하였습니다.');
$prevPage = $_SERVER['HTTP_REFERER']; // 변수에 이전페이지 정보를 저장
header('location:'.$prevPage); // 페이지 이동
include_once(G5_PATH.'/tail.sub.php');
?>

거의 대부분의 데이터 받는부분을 삭제하고

header()로 페이지이동을 한다

 

guest_formmail.skin.php

<div class="form_01 new_win_con">
<h2 class="sound_only">메일쓰기</h2>
<ul>
<?php if (!$is_member) { ?>
<li>
<label for="fnick" class="sound_only">기업명 또는 성함<strong>필수</strong></label>
<input type="text" name="fnick" id="fnick" required class="frm_input full_input required" placeholder="기업명 또는 성함">
</li>
<li>
<label for="fmail" class="sound_only">이메일<strong>필수</strong></label>
<input type="text" name="fmail" id="fmail" required class="frm_input full_input required" placeholder="이메일">
</li>
<?php } ?>
<li>
<label for="subject" class="sound_only">제목<strong>필수</strong></label>
<input type="text" name="subject" id="subject" required class="frm_input full_input required" placeholder="제목">
</li>
<li>
<label for="content" class="sound_only">내용<strong>필수</strong></label>
<textarea name="content" id="content" required class="required" placeholder="내용"></textarea>
</li>
</ul>
<div class="win_btn">
<button type="submit" id="btn_submit" class="btn_b02 reply_btn">메일발송</button>
</div>
</div>

 

반응형

최근댓글

최근글

© Copyright 2024 ttutta