2014-03-07 3 views
1

BCC에서 전자 메일 주소를 추가하는 방법을 알아 내려고하고 있습니다. 맹목적인 전자 메일 주소를 추가하기 위해 "$ headers"를 추가 했으므로 전체 코드가 더 이상 작동하지 않습니다.PHP 코드의 BCC에 전자 메일 주소 추가

<?php 
// put your email address here 
$youremail = '[email protected]'; 

// if the url field is empty 
if(isset($_POST['url']) && $_POST['url'] == ''){ 


// prepare message 
$body = "Nuovo messaggio dal sito web : 

Nome: $_POST[name] 
Azienda: $_POST[company] 
Telefono: $_POST[phone] 
Email: $_POST[email] 
Messaggio: $_POST[message]"; 

if($_POST['email'] && !preg_match("/[\r\n]/", $_POST['email'])) { 
    $headers = "From: $_POST[email]"; 
} else { 
    $headers = "From: $youremail"; 
} 
$headers .= "Bcc: [email protected]\r\n"; 

mail($youremail, 'Richiesta Informazioni dal Sito Web', $body, $headers); 

} 
?> 
+1

나는 보통 PHPMailer를 사용합니다. http://phpmailer.worxware.com/ – Populus

답변

1

당신은 너무 당신의 헤더의 첫 번째 줄에 줄 바꿈을 추가해야합니다 : 당신이 당신의 From 헤더에 라인 엔딩을 잊었다처럼

if($_POST['email'] && !preg_match("/[\r\n]/", $_POST['email'])) { 
    $headers = "From: $_POST[email]\r\n"; 
} else { 
    $headers = "From: $youremail\r\n"; 
} 
$headers .= "Bcc: [email protected]\r\n"; 

mail($youremail, 'Richiesta Informazioni dal Sito Web', $body, $headers); 

} 
+0

에 필요한 모든 작업을 수행합니다. 고맙습니다! – CFW

1

것 같습니다.

if($_POST['email'] && !preg_match("/[\r\n]/", $_POST['email'])) { 
    $headers = "From: $_POST[email]\r\n"; 
} else { 
    $headers = "From: $youremail\r\n"; 
} 
+0

감사합니다. :) – CFW