채택완료

폼메일 여러명에게 발송하고 싶다면..

Copy
<meta charset="utf-8">
<?php
$email_to = "받는사람메일입력";
$email_from = "보내는 사람 메일입력";
$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['telephone']) ||    
 !isset($_POST['company_name']) ||    
 !isset($_POST['email']) ||    
 !isset($_POST['content'])){
 died('We are sorry, but there appears to be a problem with the form you submitted.');      
}
 
$first_name = $_POST['first_name']; // required
$telephone = $_POST['telephone']; // not required
$company_name = $_POST['company_name']; // not required
$email = $_POST['email']; // not required
$content = $_POST['content']; // not 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($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($telephone)."\n\n";
$email_message .= "회사명 : ".clean_string($company_name)."\n\n";
$email_message .= "이메일 : ".clean_string($email)."\n\n";
$email_message .= "상담내용 : ".clean_string($content)."\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인데요.

여기서 $email_to = "받는사람메일입력";여기에 메일을 쓰면 메일이 보내지더라구요.

제가 웹디자이너라서 php는 할줄모르는데

혹시 2명에게 보내려면 어딜 추가해야하나요?ㅠㅠ

고수님들 도와주세요..

|

답변 3개 / 댓글 1개

채택된 답변
+20 포인트

소스를 그대로 활용할 경우

Copy
$email_to2 = "받는사람메일입력";

$email_to = "받는사람메일입력"; 아래줄에 한줄 추가하세요

 

Copy
@mail($email_to2, $email_subject, $email_message, $headers);
@mail($email_to, $email_subject, $email_message, $headers); 아래줄에 한줄 추가하세요

 

 

답변에 대한 댓글 1개

디테일한 설명 감사합니다 ㅠㅠ

복사해서 한줄더 추가하세요

저흰 메일 하나에 발송하고, 메일서비스 내에 있는 기능인 메일 보내기 기능으로 공유하고 있어요.

서버부담도 없고 이득

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