Problem in php with form sender

0

We have a php form that works correctly except that the sender is not the sender of the query but the following address [email protected]

What could be what is wrong configured in the php code?

// Read the form values
$success = false;
$senderName = isset( $_POST['name'] ) ? preg_replace( "/[^\.\-\' a-zA-Z0-9]/", "", $_POST['name'] ) : "";
$senderEmail = isset( $_POST['email'] ) ? preg_replace( "/[^\.\-\_\@a-zA-Z0-9]/", "", $_POST['email'] ) : "";
$phone = isset( $_POST['phone'] ) ? preg_replace( "/[^\.\-\' 0-9]/", "", $_POST['phone'] ) : "";
$body = isset( $_POST['message'] ) ? preg_replace( "/(From:|To:|BCC:|CC:|Subject:|Content-Type:)/", "", $_POST['message'] ) : "";
$subject = 'Petición enviada a través del formulario de contacto de Pazo Catoira';
// If all values exist, send the email
$headers = "De: " . $senderName . " <" . $senderEmail . "> To: " . RECIPIENT_NAME . " <" . RECIPIENT_EMAIL . ">";
$message = "Equipo Administrativo: ".RECIPIENT_NAME." ".$body;

if(mail(RECIPIENT_EMAIL, $subject, $message, $headers)){
       echo "<p class='success'>Gracias por contactar con Pazo Catoira. Recibirá su respuesta a la mayor brevedad posible</p>";

} else {
    echo "Su email no fue enviado";
}

?>
    
asked by Antonio 17.04.2018 в 12:01
source

1 answer

0

If I have correctly understood your problem, the point is that the email you receive originates from the email "[email protected]".

That is completely normal, since the email is actually sent by the manager that they have installed and configured on their server to perform that operation, that is, the email is actually sent by the server where their WEB is hosted and does not send it the client with its own mail manager, and that is why the "real" address of the "client" does NOT appear.

That's why they should put the customer's data that contacts them in another place, for example in the body of the message or even in the subject field.

    
answered by 17.04.2018 в 14:22