2016-05-31 1 views
-3

Wie i cc und bcc im folgenden Skripthinzufügen cc und bcc in php mail

<?php 
$name = $_POST['name']; 
$email = $_POST['email']; 
$phone = $_POST['phone']; 
$message = $_POST['message']; 
$formcontent=" From: $name \n Phone: $phone \n Call Back: $property_id \n Priority: $priority \n Type: $type \n Message: $message , $proptitle"; 
$recipient = "[email protected]"; 
$subject = "Contact Form"; 
$mailheader = "From: $email \r\n"; 
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!"); 
echo "Thank You!" . " -" . "<a href='#' style='text-decoration:none;color:#ff0099;'> Return Home</a>"; 
?> 
+0

Hat man sich [diese Seite] (http://php.net/manual/en/function.mail.php)? Dort gibt es viele Informationen. Suche (ctrl + f) nach "cc" und du findest vielleicht etwas Nützliches. – Ivar

+0

Sei vorsichtig mit der E-Mail der anderen Person im Feld "von", du solltest ihre E-Mail in die Antwort schreiben zu, siehe [Häufige Kontaktformular Fehler] (https://www.unlocktheinbox.com/resources/dmarccontactus/) – Henry

Antwort

0

Sie müssen Header gesetzt für die Einstellung cc und bcc hinzufügen:

// Always set content-type when sending HTML email 
$headers = "MIME-Version: 1.0" . "\r\n"; 
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n"; 

// More headers 
$headers .= 'From: My Name <[email protected]>'. "\r\n"; 
//Multiple CC can be added, if we need (comma separated); 
$headers .= 'Cc: [email protected], [email protected]' . "\r\n"; 
//Multiple BCC, same as CC above; 
$headers .= 'Bcc: [email protected], [email protected]' . "\r\n"; 

mail($to, $subject, $message, $headers); 
-1
**First off all you have to concat $recipient with cc and Bcc variable use like this** 
<?php 
$name = $_POST['name']; 
$email = $_POST['email']; 
$phone = $_POST['phone']; 
$message = $_POST['message']; 
$formcontent=" From: $name \n Phone: $phone \n Call Back: $property_id \n Priority: $priority \n Type: $type \n Message: $message , $proptitle"; 
$recipient = "[email protected]"; 
$recipient. = "CC: [email protected]\r\n"; 
$recipient .= "BCC: [email protected]\r\n"; 
$subject = "Contact Form"; 
$mailheader = "From: $email \r\n"; 
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!"); 
echo "Thank You!" . " -" . "<a href='#' style='text-decoration:none;color:#ff0099;'> Return Home</a>"; 
?> 
Verwandte Themen