Advertisement
Guest User

sendmail script

a guest
Aug 12th, 2010
473
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.84 KB | None | 0 0
  1. <?php
  2. if( isset($_POST["boton"]) && !strcmp($_POST["boton"], "Enviar") )
  3.     {
  4.     echo '<span>';
  5.     $boundary= md5(time()); //valor boundary
  6.     $htmlalt_boundary= $boundary. "_htmlalt"; //boundary suplementario
  7.     $subject=$_POST["asunto"];
  8.     $from= $_POST["from"];
  9.     $to= $_POST["to"];
  10.     if( !empty($_POST["return_path"]) )
  11.         $extra_arg= '-f'. $_POST["return_path"];
  12.     else        $extra_arg= NULL;
  13.  
  14.     //cabeceras para enviar correo en formato HTML
  15.     $headers = "MIME-Version: 1.0\r\n";
  16.     $headers .= "Content-Type: multipart/mixed; boundary=\"". $boundary. "\"\r\n"; //datos mixteados
  17.     $headers .= "From: ". $from. "\r\n"; //correo del que lo envia
  18.  
  19.     //incia cuerpo del mensaje que se visualiza
  20.     $cuerpo="--". $boundary. "\r\n";
  21.     $cuerpo .= "Content-Type: multipart/alternative; boundary=\"". $htmlalt_boundary. "\"\r\n\r\n"; //contenido alternativo: texto o html
  22.     $cuerpo .= "--". $htmlalt_boundary. "\r\n";
  23.     $cuerpo .= "Content-Type: text/html; charset=iso-8859-1\r\n";
  24.     $cuerpo .= "Content-Transfer-Encoding: 8bits\r\n\r\n";
  25.     $cuerpo .= $_POST["mensaje"];
  26.     $cuerpo .= "\r\n\r\n";
  27.     $cuerpo .= "--". $htmlalt_boundary. "--\r\n\r\n"; //fin cuerpo mensaje a mostrar
  28.     $cuerpo .= "--". $boundary. "--\r\n\r\n";
  29.  
  30.     if( mail($to, $subject, $cuerpo, $headers, $extra_arg) )
  31.         echo 'Correo enviado con exito...';
  32.     else
  33.         echo 'Error al enviar...';
  34.     echo '</span>';
  35.     }
  36.    
  37. echo '<table>
  38. <form action="sendmail.php" method="POST">
  39. <td>From:</td><td><input type="text" name="from"></td><tr>
  40. <td>To:</td><td><input type="text" name="to"></td><tr>
  41. <td>Return-Path:</td><td><input type="text" name="return_path"></td><tr>
  42. <td>Asunto:</td><td><input type="text" name="asunto"></td><tr>
  43. <td colspan="2">Mensaje:</td><tr>
  44. <td colspan="2"><textarea name="mensaje"></textarea></td><tr>
  45. <td colspan="2"><input type="submit" name="boton" value="Enviar"></td>
  46. </form>
  47. </table>';
  48. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement