기존 홈페이지 폼메일 발송시 메일이 정상적으로 오는데
그 소스를 그대로 새로 제작한 홈페이지에 쓰는데
새로 제작한 홈페이지는 메일 발송 완료메세지는 나오는데 메일은 안오네요
그누 기본 메일발송은 정상적으로 됩니다.
어떤 문제인가요..?ㅠㅠ
답변 1개 / 댓글 2개
채택된 답변
+20 포인트
devdev
2018-03-07 (수) 17:41:23
그누 기본 메일이라면 관리자 페이지 테스트 메일이 발송된다는 말인가요?
그렇다면 폼메일쪽 소스 부분이 문제라고 봐야겠네요.
폼메일 발송 부분을 보지 않고는 알 수 없겠습니다.
답변에 대한 댓글 2개
2018-03-07 (수) 22:17:49
답변을 작성하려면 로그인이 필요합니다.
<?php
if(isset($_POST['email'])) {
$email_to = "[email protected]";
$email_subject = "[폼메일] 문의사항입니다.";
$email_subject = '=?UTF-8?B?'.base64_encode($email_subject).'?=';
function died($error) {
// your error code can go here
echo "<script> alert('메일발송을 실패하였습니다.');";
echo "history.go(-1);";
echo "</script>";
die();
}
// validation expected data exists
if(!isset($_POST['first_name']) ||
!isset($_POST['email']) ||
!isset($_POST['telephone']) ||
!isset($_POST['comments'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$first_name = $_POST['first_name']; // required
$email_from = $_POST['email']; // required
$telephone = $_POST['telephone']; // not required
$comments = $_POST['comments']; // required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
if(strlen($comments) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "이름 : ".clean_string($first_name)."\n\n";
$email_message .= "이메일 : ".clean_string($email_from)."\n\n";
$email_message .= "연락처 : ".clean_string($telephone)."\n\n";
$email_message .= "문의사항 : ".clean_string($comments)."\n\n";
// create email headers
$headers = 'From: '.$email_from;
// 제목이 깨질경우 아래 캐릭터셋 적용
@mail($email_to, $email_subject, $email_message, $headers);
?>
<!-- include your own success html here -->
<script>
alert ("메일이 발송되었습니다.\n빠른 시일안에 답변드리겠습니다.");
location.href='/';
</script>
<?php
}
?>