He creado un formulario html en un archivo html.
<form action='index.html' method='post' id='contact_form'> <!-- A regular html form --> <input type='submit' id='send_message' class="button" value='Submit' /> </form>La información luego va a un archivo js
$.post("send_comment.php", $("#contact_form").serialize(), function(result) { //Sends success or fail message back to the form ... })Y luego debe ser reenviado a send_comment.php
if(mail($email_to,"A comment from" + $name,$message)){ echo 'sent'; // we are sending this text to the ajax request telling it that the mail is sent.. }else{ echo 'failed'; }Pero no recibo un correo electrónico, aunque mail() funciona en el servidor (lo probé). Tampoco estoy seguro de si el php incluso se ejecuta, ya que intenté agregar un comando para escribir "éxito" en un archivo separado solo para probar si la función funciona, pero eso nunca funcionó (Puede ser que simplemente programé mal la prueba, pero no lo creo).
¿Alguien podría decirme qué hice mal?