function ValidaMail($mail) { // Valido que no sea nulo if ($mail == "") return 0; // quito los espacios y convierto a minúsculas $mail = strtolower(chop($mail)); // me fijo si tiene punto, sino es errónea $pos = strrpos($mail,"."); if ($pos === false || $pos == 0 || $pos == (strlen($mail)-1)) return 1; // me fijo si tiene arroba, sino es errónea $pos = strrpos($mail,"@"); if ($pos === false || $pos == 0 || $pos == (strlen($mail)-1)) return 1; // la dirección es válida return 2; } $ok = 1; if($_POST) { // lists / textfields / textareas $nombre = $_POST["nombre"]; $estado = $_POST["estado"]; $municipio = $_POST["municipio"]; $poblacion = $_POST["poblacion"]; $tel1 = $_POST["tel1"]; $tel2 = $_POST["tel2"]; $cel = $_POST["cel"]; $email = $_POST["email"]; $responsable = $_POST["responsable"]; $fechaent = $_POST["fechaent"]; $dirent = $_POST["dirent"]; $alg1 = $_POST["alg1"]; $arr["alg"][0] = $_POST["alg1"]; $cant1 = $_POST["cant1"]; $arr["alg"][0] = $_POST["alg1"]; $kilos1 = $_POST["kilos1"]; $arr["alg"][0] = $_POST["alg1"]; $fila1 = $_POST["fila1"]; $arr["alg"][0] = $_POST["alg1"]; $nro1 = $_POST["nro1"]; $arr["nro1"][0] = $_POST["alg1"]; $pres1 = $_POST["pres1"]; $arr["pres"][0] = $_POST["pres1"]; $alg2 = $_POST["alg2"]; $cant2 = $_POST["cant2"]; $kilos2 = $_POST["kilos2"]; $fila2 = $_POST["fila2"]; $nro2 = $_POST["nro2"]; $pres2 = $_POST["pres2"]; $alg3 = $_POST["alg3"]; $cant3 = $_POST["cant3"]; $kilos3 = $_POST["kilos3"]; $fila3 = $_POST["fila3"]; $nro3 = $_POST["nro3"]; $pres3 = $_POST["pres3"]; $alg4 = $_POST["alg4"]; $cant4 = $_POST["cant4"]; $kilos4 = $_POST["kilos4"]; $fila4 = $_POST["fila4"]; $nro4 = $_POST["nro4"]; $pres4 = $_POST["pres4"]; $alg5 = $_POST["alg5"]; $cant5 = $_POST["cant5"]; $kilos5 = $_POST["kilos5"]; $fila5 = $_POST["fila5"]; $nro5 = $_POST["nro5"]; $pres5 = $_POST["pres5"]; $alg6 = $_POST["alg6"]; $cant6 = $_POST["cant6"]; $kilos6 = $_POST["kilos6"]; $fila6 = $_POST["fila6"]; $nro6 = $_POST["nro6"]; $pres6 = $_POST["pres6"]; $alg7 = $_POST["alg7"]; $cant7 = $_POST["cant7"]; $kilos7 = $_POST["kilos7"]; $fila7 = $_POST["fila7"]; $nro7 = $_POST["nro7"]; $pres7 = $_POST["pres7"]; $alg8 = $_POST["alg8"]; $cant8 = $_POST["cant8"]; $kilos8 = $_POST["kilos8"]; $fila8 = $_POST["fila8"]; $nro8 = $_POST["nro8"]; $pres8 = $_POST["pres8"]; $alg9 = $_POST["alg9"]; $cant9 = $_POST["cant9"]; $kilos9 = $_POST["kilos9"]; $fila9 = $_POST["fila9"]; $nro9 = $_POST["nro9"]; $pres9 = $_POST["pres9"]; $arr["alg"][0] = $_POST["alg1"]; $arr["cant"][0] = $_POST["cant1"]; $arr["kilos"][0] = $_POST["kilos1"]; $arr["fila"][0] = $_POST["fila1"]; $arr["nro"][0] = $_POST["nro1"]; $arr["pres"][0] = $_POST["pres1"]; $arr["alg"][1] = $_POST["alg2"]; $arr["cant"][1] = $_POST["cant2"]; $arr["kilos"][1] = $_POST["kilos2"]; $arr["fila"][1] = $_POST["fila2"]; $arr["nro"][1] = $_POST["nro2"]; $arr["pres"][1] = $_POST["pres2"]; $arr["alg"][2] = $_POST["alg3"]; $arr["cant"][2] = $_POST["cant3"]; $arr["kilos"][2] = $_POST["kilos3"]; $arr["fila"][2] = $_POST["fila3"]; $arr["nro"][2] = $_POST["nro3"]; $arr["pres"][2] = $_POST["pres3"]; $arr["alg"][3] = $_POST["alg4"]; $arr["cant"][3] = $_POST["cant4"]; $arr["kilos"][3] = $_POST["kilos4"]; $arr["fila"][3] = $_POST["fila4"]; $arr["nro"][3] = $_POST["nro4"]; $arr["pres"][3] = $_POST["pres4"]; $arr["alg"][4] = $_POST["alg5"]; $arr["cant"][4] = $_POST["cant5"]; $arr["kilos"][4] = $_POST["kilos5"]; $arr["fila"][4] = $_POST["fila5"]; $arr["nro"][4] = $_POST["nro5"]; $arr["pres"][4] = $_POST["pres5"]; $arr["alg"][5] = $_POST["alg6"]; $arr["cant"][5] = $_POST["cant6"]; $arr["kilos"][5] = $_POST["kilos6"]; $arr["fila"][5] = $_POST["fila6"]; $arr["nro"][5] = $_POST["nro6"]; $arr["pres"][5] = $_POST["pres6"]; $arr["alg"][6] = $_POST["alg7"]; $arr["cant"][6] = $_POST["cant7"]; $arr["kilos"][6] = $_POST["kilos7"]; $arr["fila"][6] = $_POST["fila7"]; $arr["nro"][6] = $_POST["nro7"]; $arr["pres"][6] = $_POST["pres7"]; $arr["alg"][7] = $_POST["alg8"]; $arr["cant"][7] = $_POST["cant8"]; $arr["kilos"][7] = $_POST["kilos8"]; $arr["fila"][7] = $_POST["fila8"]; $arr["nro"][7] = $_POST["nro8"]; $arr["pres"][7] = $_POST["pres8"]; $arr["alg"][8] = $_POST["alg9"]; $arr["cant"][8] = $_POST["cant9"]; $arr["kilos"][8] = $_POST["kilos9"]; $arr["fila"][8] = $_POST["fila9"]; $arr["nro"][8] = $_POST["nro9"]; $arr["pres"][8] = $_POST["pres9"]; // Required Fields if(trim($nombre) == "") { $ok=0; } if(trim($email) == "") { $ok=0; } if(trim($responsable) == "") { $ok=0; } if(trim($fechaent) == "") { $ok=0; } if(trim($dirent) == "") { $ok=0; } // Mail fields validation if(trim($email == "")) { $e_email = 1; $ok = 0; } else { if(ValidaMail(trim($email))==1) { $e_email = 1; $ok = 0; } } // Mail construction if($ok==1) { $cabeceras = 'MIME-Version: 1.0'. "\r\n"; $cabeceras .= 'Content-type: text/html; charset=UTF-8' . "\r\n"; $cabeceras .= 'From: HILOS TORZAL'."\r\n"; $cabeceras2 = 'From: HILOS TORZAL'.chr(60).'noresponder@hilostorzal.com'.chr(62)."\r\n"; $body2 = 'PEDIDO'."\r\r\n"; $body2 .= 'Nombre del cliente: '.$nombre."\r"; $body2 .= 'Estado: '.$estado."\r"; $body2 .= 'Municipio: '.$municipio."\r"; $body2 .= 'Poblacion: '.$poblacion."\r"; $body2 .= 'Tel 1: '.$tel1."\r"; $body2 .= 'Tel 2: '.$tel2."\r"; $body2 .= 'Cel: '.$cel."\r"; $body2 .= 'E-Mail: '.$email."\r"; $body2 .= 'Responsable del pedido: '.$responsable."\r"; $body2 .= 'Fecha de entrega: '.$fechaent."\r"; $body2 .= 'Direccion de entrega: '.$dirent."\r\r\n"; $body2 .= 'Descripción de pedido: '."\r\r\n"; $body2.= 'Alg / Pol / Fil: '.$alg1."\r"; $body2.= 'Cantidad: '.$cant1."\r"; $body2.= 'Kilos / Conos: '.$kilos1."\r"; $body2.= 'Fila: '.$fila1."\r"; $body2.= 'Numero: '.$nro1."\r"; $body2.= 'Presentacion: '.$pres1."\r\r\n"; $body2.= 'Alg / Pol / Fil: '.$alg2."\r"; $body2.= 'Cantidad: '.$cant2."\r"; $body2.= 'Kilos / Conos: '.$kilos2."\r"; $body2.= 'Fila: '.$fila2."\r"; $body2.= 'Numero: '.$nro2."\r"; $body2.= 'Presentacion: '.$pres2."\r\r\n"; $body2.= 'Alg / Pol / Fil: '.$alg3."\r"; $body2.= 'Cantidad: '.$cant3."\r"; $body2.= 'Kilos / Conos: '.$kilos3."\r"; $body2.= 'Fila: '.$fila3."\r"; $body2.= 'Numero: '.$nro3."\r"; $body2.= 'Presentacion: '.$pres3."\r\r\n"; $body2.= 'Alg / Pol / Fil: '.$alg4."\r"; $body2.= 'Cantidad: '.$cant4."\r"; $body2.= 'Kilos / Conos: '.$kilos4."\r"; $body2.= 'Fila: '.$fila4."\r"; $body2.= 'Numero: '.$nro4."\r"; $body2.= 'Presentacion: '.$pres4."\r\r\n"; $body2.= 'Alg / Pol / Fil: '.$alg5."\r"; $body2.= 'Cantidad: '.$cant5."\r"; $body2.= 'Kilos / Conos: '.$kilos5."\r"; $body2.= 'Fila: '.$fila5."\r"; $body2.= 'Numero: '.$nro5."\r"; $body2.= 'Presentacion: '.$pres5."\r\r\n"; $body2.= 'Alg / Pol / Fil: '.$alg6."\r"; $body2.= 'Cantidad: '.$cant6."\r"; $body2.= 'Kilos / Conos: '.$kilos6."\r"; $body2.= 'Fila: '.$fila6."\r"; $body2.= 'Numero: '.$nro6."\r"; $body2.= 'Presentacion: '.$pres6."\r\r\n"; $body2.= 'Alg / Pol / Fil: '.$alg7."\r"; $body2.= 'Cantidad: '.$cant7."\r"; $body2.= 'Kilos / Conos: '.$kilos7."\r"; $body2.= 'Fila: '.$fila7."\r"; $body2.= 'Numero: '.$nro7."\r"; $body2.= 'Presentacion: '.$pres7."\r\r\n"; $body2.= 'Alg / Pol / Fil: '.$alg8."\r"; $body2.= 'Cantidad: '.$cant8."\r"; $body2.= 'Kilos / Conos: '.$kilos8."\r"; $body2.= 'Fila: '.$fila8."\r"; $body2.= 'Numero: '.$nro8."\r"; $body2.= 'Presentacion: '.$pres8."\r\r\n"; $body2.= 'Alg / Pol / Fil: '.$alg9."\r"; $body2.= 'Cantidad: '.$cant9."\r"; $body2.= 'Kilos / Conos: '.$kilos9."\r"; $body2.= 'Fila: '.$fila9."\r"; $body2.= 'Numero: '.$nro9."\r"; $body2.= 'Presentacion: '.$pres9."\r\r\n"; //mail("morales.mariano@gmail.com","PEDIDO",$body2,$cabeceras2); mail("fmaurer@hilostorzal.com","PEDIDO",$body2,$cabeceras2); mail("ventas@hilostorzal.com","PEDIDO",$body2,$cabeceras2); } } ?>