Ver Mensaje Individual
  #4 (permalink)  
Antiguo 16/10/2007, 11:05
miczoe
 
Fecha de Ingreso: noviembre-2006
Mensajes: 102
Antigüedad: 18 años, 3 meses
Puntos: 0
Re: mails y archivos adjuntos

Código HTML:
<tr bgcolor="#993333"> 
    <td colspan="4"><form action="mail.php" method="post" enctype="multipart/form-data">
      <table width="500" border="0" align="center" cellpadding="4" cellspacing="4" bgcolor="#CC6666">
        <tr bgcolor="#993333">
          <td>Destinatario</td>
          <td><input type="text" name="destino" ></td>
        </tr>
        <tr bgcolor="#993333">
          <td>Asunto</td>
          <td><br>
              <input type="text" name="asunto"></td>
        </tr>
        <tr bgcolor="#993333">
          <td>Flyer</td>
          <td><input type="file" name="archivo"></td>
        </tr>
        <tr bgcolor="#993333">
          <td>Mensaje</td>
          <td><textarea name="mensaje"></textarea></td>
        </tr>
        <tr bgcolor="#993333">
          <td><span class="Estilo6"></span></td>
          <td><input type="submit" name="btsend" value="Enviar Email">
              <input type="hidden" name="action" value="send" /></td>
        </tr>
        <tr bgcolor="#993333">
          <td colspan="2"><span class="Estilo6"></span><span class="Estilo6"></span><span class="Estilo6"></span></td>
          </tr>
      </table>
    </form></td>
  </tr> 
mail.php
Código PHP:
<?php 

      
require("class.phpmailer.php"); 

      if (
$_POST['action'] == "send") {

          
$varname $_FILES['archivo']['name'];
 
          
$vartemp $_FILES['archivo']['tmp_name'];
         

          
$mail = new PHPMailer();
 
          
$mail->Host "localhost";

          
$mail->From "[email protected]";

          
$mail->FromName "Z";

          
$mail->Subject $_POST['asunto'];

          
$mail->AddAddress($_POST['destino']);

          if (
$varname != "") {

              
$mail->AddAttachment($vartemp$varname);

          }

          
$body "<strong>Mensaje</strong><br><br>";
          

          
$body.= $_POST['mensaje']."<br>";

          
$body.= "<i>Enviado por http://www.z.com.ar . </i></p>
<p><i>Si no desea recibir mas información, responda este correo con asunto ELIMINAR.</i>
</p>"
;

          
$mail->Body $body;
    

          
$mail->IsHTML(true);

          
$mail->Send();

      }
echo 
"su mensaje ha sido enviado satisfactoriamente";

?>
no olvides de subir al servidor la class.phpmailer.php class.smtp.php