Tema: Email php
Ver Mensaje Individual
  #3 (permalink)  
Antiguo 09/09/2009, 20:22
Avatar de emiliodeg
emiliodeg
 
Fecha de Ingreso: septiembre-2005
Ubicación: Córdoba
Mensajes: 1.830
Antigüedad: 18 años, 8 meses
Puntos: 55
Respuesta: Email php

bueno proba con esto, ojo con los datos del smtp esos son tuyos

Código PHP:
<?php
require("class.phpmailer.php");
require(
"class.smtp.php");
$msg "";
if (
$_POST['action'] == "send") {
    
$varname $_FILES['archivo']['name'];
    
$vartemp $_FILES['archivo']['tmp_name'];
    
    
$mail = new PHPMailer();
    
$mail->IsSMTP();
    
$mail->SMTPAuth true;
    
$mail->SMTPSecure "ssl";
    
$mail->Host "smtp.mail.yahoo.com";
    
$mail->Port 587;
    
$mail->Username "correoyahoo.es";
    
$mail->Password "password";
    
$mail->From "correoyahoo.es";
    
$mail->FromName "alguno";
    
$mail->Subject $_POST['asunto'];
    
$mail->AddAddress($_POST['destino']);
    if (
$varname != "") {
        
$mail->AddAttachment($vartemp$varname);
    }
    
$body "<strong>Mensaje</strong><br /><div>".$_POST['mensaje']."</div>";
    
$mail->Body $body;
    
$mail->IsHTML(true);
    if(
$mail->Send()){
    
$msg "Mensaje enviado correctamente";
}else{
$msg "error al enviar mensaje";
}
}
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>PHP Email Attach</title>
<link href="mailattach.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td align="center" class="descdet">
    <div class="borde">
    <strong class="subder">Env&iacute;ar Email con Adjuntos</strong><br>
    Ingresar los datos en el formulario. <br>
    <?php if ($msg != "") { ?><span class="conf"><?php echo $msg?></span><br><?php ?>
    <form action="mailattach.php" method="post" enctype="multipart/form-data">
      <p>      Destinatario<br>
      <input type="text" name="destino" size="50">
      Asunto<br>
      <input type="text" name="asunto" size="50">
      Adjunto<br>
      <input type="file" name="archivo"  size="32">
      Mensaje<br>
      <textarea name="mensaje" cols="47" rows="8" wrap="virtual" id="mensaje"></textarea>
      <input type="submit" name="btsend" class="boton" value="Enviar Email">
      <input type="hidden" name="action" value="send" />
      </p>
    </form>
    </div>
    </td>
  </tr>
</table>
</body>
</html>
__________________
Degiovanni Emilio
developtus.com