Usá este código:
Son dos archivos!
1º:
Código:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Envia mails</title>
</head>
<script type="text/javascript">
///----Funcion que envía datos!!!!
function enviar(){
if(document.FormEnvia.nombreApell.value!="" && document.FormEnvia.mailContacto.value!="" && document.FormEnvia.txtDetalle.value!=""){
document.FormEnvia.submit();
return true;
}else{
alert("Error: debe completar todos los campos!");
return false;
}
}
</script>
<body>
<form action="Proc_enviar mails.php" name="FormEnvia" method="post">
<table>
<tr>
<td>Nombre y Apellido</td><td><input name="nombreApell" type="text" maxlength="250"/></td>
</tr>
<tr>
<td>Mail contacto</td><td><input name="mailContacto" type="text" maxlength="250"/></td>
</tr>
<tr>
<td colspan="2"><textarea style="height:110px; width:275px;" name="txtDetalle"></textarea></td>
</tr>
<tr>
<td colspan="2"><input type="button" value="Enviar" onClick="enviar();"></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<? if(isset($_GET['envio'])){ ?>
<tr>
<td colspan="2">El mail ha sido enviado!!!!</td>
</tr>
<? } ?>
</table>
</form>
</body>
</html>
2º Archivo, el que envía!
Código:
<?
//---Recupero los datos!!!
$nombreApell = $_POST['nombreApell'];
$mailContacto = $_POST['mailContacto'];
$txtDetalle = $_POST['txtDetalle'];
$to = "direccion donde llegaran los mails!!";
$from = "[email protected]";
$headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: ".$from ."\r\n";
$asunto = "Asunto de prueba";
mail($to,$asunto,nl2br(htmlentities($txtDetalle)), $headers);
echo "<script language=javascript> location = 'frm_enviar.php?&envio=ok';</script>";
?>
Espero que te sirva. Funciona 100%
Siempre y cuando esté bien configurado php!
De utilizar un hosting solicita ayuda al contacto de soporte de tu hosting. Muchas veces tenés que poner en lugar de
[email protected] una dirección válida de tu host.
Saludos, Felipe