enviar mail
Publicado por Mateo (1 intervención) el 17/10/2005 23:30:43
holas
he creado un form en el cual los visitantes pueden enviar sus consultas
en el se valida q halla ingresado el nombre, el correo, el asunto y el mensaje
todo funcionaba bien hasta q me pidieron q el usuario seleccione el el area q va a recibir el correo
he tratado de varias maneras y naaa ....... a ver si alguien me da una manito
aca esta el codigo
----------------------------------------------------------------
<html><head><title>:::::: Contactenos :::::::</title></head>
<body bgcolor="#ffffff" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" width=70%>
<?php
$admin_mail="administrador@hotmail";
$otros_mail="[email protected]";
$inicio_msg="Por favor llene los campos correctamente";
$gracias_msg="<b>Muchas Gracias</b><br><br>su correo ha sido enviado correctamente.";
$nombre_error="Error: <b>NOMBRE</b>.";
$email_error="Error: <b>E-MAIL</b>.";
$area_error="Error: <b>AREA</b>.";
$asunto_error="Error: <b>ASUNTO</b>";
$message_error="Error: <b>MENSAJE</b>.";
$msg=$inicio_msg;
$tabadd=true;
$tabthank=false;
$black="#000099";
$red="#ff0000";
if($send){
if(empty($tunombre)){ $msg=$nombre_error; $font_c=$red; }
if(empty($tuemail)){ $msg=$email_error; $font_c=$red; }
if(empty($tuarea)){ $msg=$area_error; $font_c=$red; }
if(empty($tuasunto)){ $msg=$asunto_error; $font_c=$red; }
if(empty($tumsg)){ $msg=$message_error; $font_c=$red; }
else if( ($tumsg) && ($tuasunto) && ($tuemail) && ($tunombre)){
$mail_msg="Nombre: $tunombre\nArea : $tuarea\n\n$tumsg\n ";
if (this.tuarea.value==v2){ $send_mail= mail ($otro_mail,$tuasunto, $mail_msg, "From: $tuemail");}
else{ $send_mail= mail ($admin_mail,$tuasunto, $mail_msg, "From: $tuemail");}
// $send_mail= mail ($admin_mail,$tuasunto, $mail_msg, "From: $tuemail");
$tabadd=false;
$tabthank=true;
$msg=false;
}
}
?>
<TABLE cellSpacing=0 cellPadding=0 border=0 align=center leftmargin="0" topmargin="0" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:7pt ">
<TBODY><tr><td colspan=3 width="300" >
<table width="300" border="0" align="center" cellpadding="0" cellspacing="0" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:7pt ">
<tr><td width="300" height="30" align="center" valign="middle" >
<font color="<?php echo"$font_c";?>"> <?php echo"$msg";?></font>
<?php if ($tabadd){ ?></td></tr>
<tr><td align="center" valign="top">
<form action="/contacto1.php" method="post" >
<table width="300" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#ffffff" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:7pt ">
<tr><td width="70" height="25"> <b>Nombre :</b></td><td width="230"><input name="tunombre" type="text" value="<?php echo "$tunombre"; ?>" size="30" style="font-family:Verdana, Arial; font-size:7pt"> * </td></tr>
<tr><td height="25"> <b>E-mail :</b></td><td ><input name="tuemail" type="text" value="<?php echo "$tuemail"; ?>" size="30" style="font-family:Verdana, Arial; font-size:7pt"> * </td></tr>
<tr><td height="25"> <b>Asunto :</b></td><td ><input name="tuasunto" type="text" value="<?php echo "$tuasunto"; ?>" size="30" style="font-family:Verdana, Arial; font-size:7pt"> * </td></tr>
<tr><td height="25"> <b>Area :</b></td><td ><select name="tuarea" style="font-family:Verdana, font-size:7pt">
<option value="v1">valor1</option><option value="v2">valor 2</option><option value="v3"> valor 3</option></select></td></tr>
<tr><td > <b>Mensaje :</b></td><td ><textarea name="tumsg" cols="41" rows="6" wrap="VIRTUAL" style="font-family:Verdana, Arial; font-size:7pt"><?php echo "$tumsg"; ?></textarea></td></tr>
<tr><td align="right" valign="bottom" colspan=2 height="35"><input name="send" type="submit" value="Enviar" style="HEIGHT: 24px; WIDTH: 84px"> </td></tr>
</table>
</form>
<?php } ?>
<table width="290" cellpadding="0" cellspacing="0" border="0" style="font-size:8pt; font-family:Verdana, Arial ">
<tr><td height="20" align="center" colspan="2"></td></tr>
<tr><td width="25" align=center><?php if($tabthank){ ?></td>
<td width="265" ><?php echo"$gracias_msg"; ?></td></tr>
<tr><td height="100" align="center" colspan="2"></td></tr>
<tr><td height="50" align="center" colspan="2"><a href="javascript:cerrar();" style="color:#0000CC ">>> cerrar ventana </a></td></tr>
<tr><td height="100" align="center" colspan="2"></td></tr>
</table>
</td>
</tr>
</table>
<?php } ?>
</TD>
</TR>
</TBODY></TABLE>
</body>
----------------------------------------------------------------
de ser posible tambien quisiera q valide q el correo contenga los valores @ y ., pero lo primero es primordial
GRACIAS
he creado un form en el cual los visitantes pueden enviar sus consultas
en el se valida q halla ingresado el nombre, el correo, el asunto y el mensaje
todo funcionaba bien hasta q me pidieron q el usuario seleccione el el area q va a recibir el correo
he tratado de varias maneras y naaa ....... a ver si alguien me da una manito
aca esta el codigo
----------------------------------------------------------------
<html><head><title>:::::: Contactenos :::::::</title></head>
<body bgcolor="#ffffff" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" width=70%>
<?php
$admin_mail="administrador@hotmail";
$otros_mail="[email protected]";
$inicio_msg="Por favor llene los campos correctamente";
$gracias_msg="<b>Muchas Gracias</b><br><br>su correo ha sido enviado correctamente.";
$nombre_error="Error: <b>NOMBRE</b>.";
$email_error="Error: <b>E-MAIL</b>.";
$area_error="Error: <b>AREA</b>.";
$asunto_error="Error: <b>ASUNTO</b>";
$message_error="Error: <b>MENSAJE</b>.";
$msg=$inicio_msg;
$tabadd=true;
$tabthank=false;
$black="#000099";
$red="#ff0000";
if($send){
if(empty($tunombre)){ $msg=$nombre_error; $font_c=$red; }
if(empty($tuemail)){ $msg=$email_error; $font_c=$red; }
if(empty($tuarea)){ $msg=$area_error; $font_c=$red; }
if(empty($tuasunto)){ $msg=$asunto_error; $font_c=$red; }
if(empty($tumsg)){ $msg=$message_error; $font_c=$red; }
else if( ($tumsg) && ($tuasunto) && ($tuemail) && ($tunombre)){
$mail_msg="Nombre: $tunombre\nArea : $tuarea\n\n$tumsg\n ";
if (this.tuarea.value==v2){ $send_mail= mail ($otro_mail,$tuasunto, $mail_msg, "From: $tuemail");}
else{ $send_mail= mail ($admin_mail,$tuasunto, $mail_msg, "From: $tuemail");}
// $send_mail= mail ($admin_mail,$tuasunto, $mail_msg, "From: $tuemail");
$tabadd=false;
$tabthank=true;
$msg=false;
}
}
?>
<TABLE cellSpacing=0 cellPadding=0 border=0 align=center leftmargin="0" topmargin="0" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:7pt ">
<TBODY><tr><td colspan=3 width="300" >
<table width="300" border="0" align="center" cellpadding="0" cellspacing="0" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:7pt ">
<tr><td width="300" height="30" align="center" valign="middle" >
<font color="<?php echo"$font_c";?>"> <?php echo"$msg";?></font>
<?php if ($tabadd){ ?></td></tr>
<tr><td align="center" valign="top">
<form action="/contacto1.php" method="post" >
<table width="300" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#ffffff" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:7pt ">
<tr><td width="70" height="25"> <b>Nombre :</b></td><td width="230"><input name="tunombre" type="text" value="<?php echo "$tunombre"; ?>" size="30" style="font-family:Verdana, Arial; font-size:7pt"> * </td></tr>
<tr><td height="25"> <b>E-mail :</b></td><td ><input name="tuemail" type="text" value="<?php echo "$tuemail"; ?>" size="30" style="font-family:Verdana, Arial; font-size:7pt"> * </td></tr>
<tr><td height="25"> <b>Asunto :</b></td><td ><input name="tuasunto" type="text" value="<?php echo "$tuasunto"; ?>" size="30" style="font-family:Verdana, Arial; font-size:7pt"> * </td></tr>
<tr><td height="25"> <b>Area :</b></td><td ><select name="tuarea" style="font-family:Verdana, font-size:7pt">
<option value="v1">valor1</option><option value="v2">valor 2</option><option value="v3"> valor 3</option></select></td></tr>
<tr><td > <b>Mensaje :</b></td><td ><textarea name="tumsg" cols="41" rows="6" wrap="VIRTUAL" style="font-family:Verdana, Arial; font-size:7pt"><?php echo "$tumsg"; ?></textarea></td></tr>
<tr><td align="right" valign="bottom" colspan=2 height="35"><input name="send" type="submit" value="Enviar" style="HEIGHT: 24px; WIDTH: 84px"> </td></tr>
</table>
</form>
<?php } ?>
<table width="290" cellpadding="0" cellspacing="0" border="0" style="font-size:8pt; font-family:Verdana, Arial ">
<tr><td height="20" align="center" colspan="2"></td></tr>
<tr><td width="25" align=center><?php if($tabthank){ ?></td>
<td width="265" ><?php echo"$gracias_msg"; ?></td></tr>
<tr><td height="100" align="center" colspan="2"></td></tr>
<tr><td height="50" align="center" colspan="2"><a href="javascript:cerrar();" style="color:#0000CC ">>> cerrar ventana </a></td></tr>
<tr><td height="100" align="center" colspan="2"></td></tr>
</table>
</td>
</tr>
</table>
<?php } ?>
</TD>
</TR>
</TBODY></TABLE>
</body>
----------------------------------------------------------------
de ser posible tambien quisiera q valide q el correo contenga los valores @ y ., pero lo primero es primordial
GRACIAS
Valora esta pregunta


0