Ver Mensaje Individual
  #4 (permalink)  
Antiguo 24/03/2005, 08:40
dultard
 
Fecha de Ingreso: mayo-2003
Ubicación: barcelona
Mensajes: 19
Antigüedad: 20 años, 10 meses
Puntos: 0
Gracias a los dos. Ahí va el php, que está sacado de la misma página de phpmailer. De los 2 archivos, el 1º es un html que recoge el archivo a adjuntar y lo manda al segundo archivo, php, que es el que envía el mail:

<html><head><title>FORMULARI</title></head><body>
<form ENCTYPE="multipart/form-data" action="exemple_fet_albert.php" method="post">
$arxiu_adjunt:
<INPUT type="file" name="arxiu_adjunt"><br>
<INPUT type="hidden" name="lim_tamany" value="100000">
<br><br>
<input type="submit" name="enviar" value="enviar!">
<input type="reset" name="borrar" value="borrar">
</form></body></html>


Y este es el 2º:


<?
echo $arxiu_adjunt."<br>";

$miau=explode("\\",$arxiu_adjunt);
$quants=count($miau);
//echo "llargada de miau: ".$quants."<br>";
$arxiu_adjunt=$miau[0];
for($i=1;$i<$quants;$i++){
$arxiu_adjunt .= "/".$miau[$i];
}
echo $arxiu_adjunt."<br>";

echo $arxiu_adjunt_size."<br>";
echo $arxiu_adjunt_name."<br>";


if ($arxiu_adjunt != "none" AND $arxiu_adjunt_size != 0 AND $arxiu_adjunt_size<=$lim_tamany){

require("class.phpmailer.php");

$mail = new PHPMailer();

$mail->From = "[email protected]";
$mail->FromName = "proves_meves";
//$mail->Host = "smtp1.site.com;smtp2.site.com";
$mail->Host = "localhost";

$mail->Mailer = "smtp";

$email_to="[email protected]";
$full_name_to="albert";
//$arxiu_adjunt=;
$arxiu_adjunt_nom=$arxiu_adjunt_name;

// HTML body
$body = "Hello <font size=\"4\">" . $full_name_to . "</font>, <p>";
$body .= "<i>Your</i> personal photograph to this message.<p>";
$body .= "Sincerely, <br>";
$body .= "PHPMailer List manager";

// Plain text body (for mail clients that cannot read HTML)
$text_body = "Hello " . $full_name_to . ", \n\n";
$text_body .= "Your personal photograph to this message.\n\n";
$text_body .= "Sincerely, \n";
$text_body .= "PHPMailer List manager";

$mail->Body = $body;
$mail->AltBody = $text_body;
$mail->AddAddress($email_to, $full_name_to);
$mail->AddStringAttachment($arxiu_adjunt, $arxiu_adjunt_nom);

if(!$mail->Send())
echo "There has been a mail error sending to " . $email_to . "<br>";

// Clear all addresses and attachments for next loop
$mail->ClearAddresses();
$mail->ClearAttachments();

}else{
echo "l'arxiu pesa més de 100Kb, pel que no s'ha enviat<br>";
echo "<a href='formulari.html'>canviar d'arxiu</a><br>";
}
?>