Ver Mensaje Individual
  #11 (permalink)  
Antiguo 06/07/2006, 12:55
exist
 
Fecha de Ingreso: julio-2006
Mensajes: 45
Antigüedad: 17 años, 10 meses
Puntos: 0
bueno , aqui esta todo lo que necesitas

Copy->Paste , no me gusta este modo , pero bueno

Código PHP:
<?php

function sendMail ($email,$from,$subject,$message)    {
    
    if(
preg_match('/^[A-Z0-9._-]+@[A-Z0-9.-]+\.[A-Z]{2,6}$/i'$email)) {

        
$to $email ', '// note the comma
        
        
$headers 'MIME-Version: 1.0' "\r\n";
        
$headers .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";

// Additional headers
        
$headers .= 'To: '.$email.' ' "\r\n";
        
$headers .= 'From: '.$from.' <'.$_SERVER['HTTP_HOST'].'>' "\r\n";
// Mail it

        
if (!@mail($to$subject$message$headers))
            return 
true;
        return 
false;
    }
    else 
        return -
1;    

}


// Main of script
    
if (isset($_POST['submit']))    {
    
    
$post = array ();
    
    foreach (
$_POST as $key=>$value)    {
        
        
$post[$key] = addslashes($value);
    
    }
    
    
$message "
                Nombre: {$post['nombre']} <br>
                Apellidos: {$post['apellidos']} <br>
                Asunto: {$post['asunto']} <br>
                <hr>
                Comentario: {$post['contents']} <br>
               "
;
    
    
$email_to_send "[email protected]"// change this 
    
$err sendMail($email_to_send,"from my site","subject",$message);
    
    if (!
err)
        die (
"Can't send the email");
    else 
        
$msg "The message was sent";
    } 

 
// End of script

?>
Código HTML:
<form name="form1" method="post" action="<?=$_SERVER['PHP_SELF'] ?>">
			<div style="font-size:14px;color:red">
			<?php
				if ($msg) echo $msg; 
			?>
			</div>
                <table width="200" border="0">
                  <tr>
                    <td><span class="Estilo15">Nombre </span></td>
                    <td><span class="Estilo15">
                      <label>
                      <input type="text" name="nombre">
                      </label>
                    </span></td>
                    <td><span class="Estilo16"></span></td>
                  </tr>
                  <tr>
                    <td><span class="Estilo15">Apellidos </span></td>
                    <td><span class="Estilo15">
                      <label>
                      <input type="text" name="apellidos">
                      </label>
                    </span></td>
                    <td><span class="Estilo16"></span></td>
                  </tr>
                  <tr>
                    <td><span class="Estilo15">Asunto</span></td>
                    <td><span class="Estilo15">
                      <label>
                      <select name="asunto">
                        <option value="Comentario sobre Web Site">Comentario sobre Web Site</option>
                        <option value="Ampliar Informacion sobre Consultoria">Ampliar Informacion sobre Consultoria</option>
                        <option value="Ampliar Informacion sobre eventos">Ampliar Informacion sobre eventos</option>
                        <option value="Proponer un Evento">Proponer un Evento</option>
                        <option value="Solicitud de Licencias">Solicitud de Licencias</option>
                        <option value="Capacitacion Privada">Capacitacion Privada</option>
                        <option value="Otro tema de Contacto">Otro tema de Contacto</option>
                      </select>
                      </label>
                    </span></td>
                    <td><span class="Estilo16"></span></td>
                  </tr>
                  <tr>
                    <td colspan="3"><span class="Estilo15">
                      <label>Comentario
                      <textarea name="contents" cols="30" rows="8"></textarea>  
                      
                    <!-- Added by exist -->
                    
                      </label>
                      <br />
                      <label for="submit">Click this button to enviar email</label>
                      <input type="submit" name="submit" value="Click me" />
                     </span>
                    </td>
                  </tr>
                </table>
       </form>