폼메일 메일 주소 추가방법 채택완료
웅라탄
3년 전
조회 1,823
</p>
<p><meta charset="utf-8">
<?php
if(isset($_POST['email'])) {</p>
<p>
$email_to = "메일주소";
$email_subject = "메일제목";
$email_subject = '=?UTF-8?B?'.base64_encode($email_subject).'?=';</p>
<p> function died($error) {
// your error code can go here
echo "<script> alert('올바른 메일주소를 입력하세요.');";
echo "history.go(-1);";
echo "</script>";
die();
}</p>
<p> // 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.');
}</p>
<p> $first_name = $_POST['first_name']; // required
$email_from = $_POST['email']; // required
$telephone = $_POST['telephone']; // not required
$comments = $_POST['comments']; // required</p>
<p> $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.
';
}</p>
<p> if(strlen($comments) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.
';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "";</p>
<p> function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}</p>
<p> $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";</p>
<p>
// create email headers
$headers = 'From: '.$email_from;
// 제목이 깨질경우 아래 캐릭터셋 적용</p>
<p> @mail($email_to, $email_subject, $email_message, $headers);
?></p>
<p><!-- include your own success html here --></p>
<p><script>
alert ("상담신청이 접수되었습니다.\n빠른 시일안에 답변드리겠습니다.");
location.href='../';
</script></p>
<p><?php
}
?></p>
<p>
이런 메일폼을 사용중인데, 메일 받는 주소를 하나 추가하고 싶으면 어떻게 수정하면 될까요ㅛㅠㅠ?
댓글을 작성하려면 로그인이 필요합니다.
답변 1개
채택된 답변
+20 포인트
3년 전
고민크게 하실거 없을듯합니다.
그냥 간단하게 두번 발송해버리면 됩니다.
</p>
<p>// create email headers
$headers = 'From: '.$email_from;
// 제목이 깨질경우 아래 캐릭터셋 적용
@mail($email_to, $email_subject, $email_message, $headers);
@mail('이메일주소', $email_subject, $email_message, $headers); // 간단하게 이렇게 추가만 하시면됩니다.</p>
<p>
로그인 후 평가할 수 있습니다
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인