Ciao a tutti!
Ho letto un pò nei vari post alla ricerca di una possibile soluzione al problema che sto avendo con un form mail; purtroppo non ho trovato riscontri...ed eccomi qui, a chiedervi un parere e un possibile aiuto.
Questo Fetente (il form...) prima funzionava su un provider, con server windows...
Il sito è stato spostato su un altro provider, con server apache...
E da allora non c'è stato più verso di fargli inviare mails.
Il codice php:
Codice PHP:
<?php $email_text = ""; foreach($_POST as $key => $value){ if($value != ""){$email_text.="
".ucfirst(str_replace("_", " ",$key))." - ".stripcslashes($value);} } $to = "miosito@miosito.it"; //Your email address goes here. $subject = "Contact Form Message"; //Subject line of the email you recieve $header = "MIME-Version: 1.0\n" . "Content-type: text/html; charset=utf-8\n"; if(mail($to, $subject, $email_text, $header)){ //This message gets display to user on success echo "
Thank you for your
message.
I'll be in touch as
soon as possible."; }else{ //Message displayed to user on failure echo "Error!"; } ?>
Il codice JS:
codice:
jQuery.iFormValidate = { build : function(options) { var defaults = { phpFile:"send.php", ajax: true }; var options = $.extend(defaults, options); return $(this).each( function() { $inputs = $(this).find(":input").filter(":not(:submit)"); $(this).submit(function(){ var isValid = jQuery.iFormValidate.validateForm($inputs); if(!isValid){ return false; }; if(options.ajax){ var data = {}; $inputs.each(function(){ data[this.name] = this.value }); $inputs.each(function(){ data[this.name] = this.value }); $(this).parent('div').fadeOut("slow"); $(this).parent('div').load(options.phpFile, data, function(){ $(this).fadeIn("slow"); }); return false; }else{ return true; } }); $inputs.bind("keyup", jQuery.iFormValidate.validate); $inputs.filter("select").bind("change", jQuery.iFormValidate.validate); }); }, validateForm : function($inputs) { var isValid = true; //benifit of the doubt? $inputs.filter(".is_required").each(jQuery.iFormValidate.validate); if($inputs.filter(".is_required").hasClass("invalid")){isValid=false;} return isValid; }, validate : function(){ var $val = $(this).val(); var isValid = true; //Regex for DATE if($(this).hasClass('vdate')){ var Regex = /^([\d]|1[0,1,2]|0[1-9])(\-|\/|\.)([0-9]|[0,1,2][0-9]|3[0,1])(\-|\/|\.)\d{4}$/; isValid = Regex.test($val); //Regex for Email }else if($(this).hasClass('vemail')){ var Regex =/^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; if(!Regex.test($val)){isValid = false;}; //Regex for Phone }else if($(this).hasClass('vphone')){ var Regex =/^([0-9a-zA-Z]+([_+.-]?[0-9a-zA-Z]+)*@[0-9a-zA-Z]+[0-9,a-z,A-Z,.,-]*(.){1}[a-zA-Z]{2,4})+$/; //var Regex = /^\(?[2-9]\d{2}[ \-\)] ?\d{3}[\- ]?\d{4}$/; if(!Regex.test($val)){isValid = false;} //Check for empty }else if($val.length == 0){ isValid = false; } if(isValid){ $(this).removeClass("invalid"); $(this).addClass("valid"); }else{ $(this).removeClass("valid"); $(this).addClass("invalid"); } return isValid; } } jQuery.fn.FormValidate = jQuery.iFormValidate.build; $(document).ready(function () { $('#myform').FormValidate({ //This path is relative to the page using it. phpFile:"js/send.php", ajax:true }); });
Nel sito in questione è presente un .htaccess che comprime di tutto...
Inizialmente pensavo fosse a causa sua; ma anche rimuovendolo in Form proprio non ne vuole sapere di inviare mail e restituisce sempre il messaggio di errore.
Grazie mille!