2011-11-07 5 views
0

나는 내 요구 사항을 충족시키기 위해 수정 한 스크립트를 가지고 있지만 이제는 둘 이상의 사람에게 전자 메일을 보내야합니다. 누군가 내가 올바른 방향으로 나를 가리킬 수 있었습니까? 둘 이상의 사람에게 보내도록 스크립트를 수정하십시오. 선의두 번째 전자 메일 주소를 스크립트에 추가하십시오.

<?php 
if(isset($_POST['email'])) { 

    // EDIT THE 2 LINES BELOW AS REQUIRED 
    $email_to = "[email protected]"; 
    $email_subject = "Kro Catering Website Enquiry"; 


    function died($error) { 
     // your error code can go here 
     echo "We are very sorry, but there were error(s) found with the form you submitted. "; 
     echo "These errors appear below.<br /><br />"; 
     echo $error."<br /><br />"; 
     echo "Please go back and fix these errors.<br /><br />"; 
     die(); 
    } 

    // validation expected data exists 
    if(!isset($_POST['your_name']) || 
     !isset($_POST['type']) || 
     !isset($_POST['guests']) || 
     !isset($_POST['date']) || 
     !isset($_POST['phone']) || 
     !isset($_POST['email'])) { 
     died('We are sorry, but there appears to be a problem with the form you submitted.');  
    } 

    $your_name = $_POST['your_name']; // required 
    $type = $_POST['type']; // required 
    $guests = $_POST['guests']; // required 
    $date = $_POST['date']; // not required 
    $phone = $_POST['phone']; // required 
    $email_from = $_POST['email']; // required 

    $email_message = "Form details below.\n\n"; 

    function clean_string($string) { 
     $bad = array("content-type","bcc:","to:","cc:","href"); 
     return str_replace($bad,"",$string); 
    } 

    $email_message .= "Your Name: ".clean_string($your_name)."\n"; 
    $email_message .= "Type: ".clean_string($type)."\n"; 
    $email_message .= "Guests: ".clean_string($guests)."\n"; 
    $email_message .= "Date: ".clean_string($date)."\n"; 
    $email_message .= "Phone: ".clean_string($phone)."\n"; 
    $email_message .= "Email: ".clean_string($email_from)."\n"; 


// create email headers 
$headers = 'From: '.$email_from."\r\n". 
'Reply-To: '.$email_from."\r\n" . 
'X-Mailer: PHP/' . phpversion(); 
@mail($email_to, $email_subject, $email_message, $headers); 
?> 

<!-- include your own success html here --> 

<?php 

    header('Location: /thanks.aspx') ; 

?> 

<?php 
} 
?> 

답변

2

이 올 때 PHP의 mail() 기능은 매우 다양한입니다 " "필드에. See the documentation here. 나열된 예 중 하나는 잘 될 것입니다 : 당신의 $email_to 변수가이 라인 5를 설정 한 후 수정 청소하거나되지 않기 때문에

[email protected] 
[email protected], [email protected] 
User <[email protected]> 
User <[email protected]>, Another User <[email protected]> 

그래서, 당신은 단지 쉼표 (,)로이 분리 된 2를 넣어 수 있어야한다 (위의 예에서와 같이 내가 연결된 문서를 복사했습니다.

+0

실제 문서를 찾기 위해 여분의 시간을 들여 다시 한번 화상을 입었습니다. – jedwards

0

시도해보십시오! 그것은 나를 위해 일한 유일한 코드입니다.

$header .= 'Bcc: [email protected]'; 
관련 문제