Well, my problem is that I'm using PHP from a template that I bought to make a form, but I can't figure out how to modify it so that when the user sends their query, it doesn't just reach the receiving mail, but a copy is sent to other emails.
I leave the PHP that I am using
From already thank you very much!
<?php
$to = '[email protected]';
$name = $_POST['name'];
$tel = $_POST['tel'];
$subject = $_POST['subject'];
$email = $_POST['email'];
$message = $_POST['message'];
// Email Submit
// Note: filter_var() requires PHP >= 5.2.0
if ( isset($email) && isset($name) && isset($tel) && isset($subject)
&& isset($message) && filter_var($email, FILTER_VALIDATE_EMAIL) ) {
// detect & prevent header injections
$test = "/(content-type|bcc:|cc:|to:)/i";
foreach ( $_POST as $key => $val ) {
if ( preg_match( $test, $val ) ) {
exit;
}
}
$body = <<<EMAIL
ASUNTO : $subject
HOLA MI NOMBRE ES, $name.
$message
DE : $name
TEL : $tel
MAIL : $email
EMAIL;
$header = 'From: ' . $_POST["name"] . '<' . $_POST["email"] . '>' . "\r\n" .
'Reply-To: ' . $_POST["email"] . "\r\n" .
'X-Mailer: PHP/' . phpversion();
//
// mail( $to , $_POST['subject'], $_POST['message'], $headers );
mail($to, $subject, $body, $header);
// ^
// Replace with your email
}?>
In the part
$header
that you have, you must add the CC/BCC to it, following your code:Here you have the manual of the function
mail
and its use (in Example #4 you would see what you need). I also recommend you use PHPMailer if you are going to work more with emails.Add to the headers: Bcc: email_de_copy.
In this case:
add this