Я хочу добавить bcc в мой файл php функции почты.
if(isset($_POST['fname']) && isset($_POST['lname']) && isset($_POST['email']) && isset($_POST['phone']) && isset($_POST['message'])){
if(!empty($_POST['fname']) && !empty($_POST['lname']) && !empty($_POST['email']) && !empty($_POST['phone']) && !empty($_POST['message'])){
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$message = $_POST['message'];
if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {
echo'Please feel valid email';
}
else {
$to='[email protected], [email protected], [email protected]';
$body = $fname."\n". $lname."\n" . $phone."\n" . $email."\n" . $message;
if(mail($to , $fname." ".$lname , $body ,'From: [email protected]')) {
header('Location: thank-you.html');
exit();
}
else {
echo "Something went wrong!";
}
}
}
else {
echo 'Please Fill All Inputs';
}
}
else {
echo 'not okk';
}
echo "<meta http-equiv='refresh' content='0; url=http://merakihotels.in/demo/'>";
добавить в шапку:
$headers[] = 'Bcc: [email protected]';
для вашего кода:
mail($to , $fname." ".$lname , $body ,'From: [email protected]' . "\r\n" . 'Bcc: [email protected]')
Хотя не решено, то попробуйте:
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: FromName<[email protected]>' . "\r\n";
$headers .= 'BCC: Someone<[email protected]>' . "\r\n";
mail($to, $subject, $message, $headers);
Просто добавь BCC:with your email id
в headers
параметр.
$headers="From: [email protected]\r\n";
$headers.="BCC:WRITE HERE YOUR EMAIL ID";
mail($to , $fname." ".$lname , $body ,$headers);