Ver Mensaje Individual
  #4 (permalink)  
Antiguo 28/02/2011, 13:16
fredyossa
 
Fecha de Ingreso: agosto-2008
Mensajes: 19
Antigüedad: 15 años, 8 meses
Puntos: 5
Respuesta: enviar archivo mp3 en mi servidor por correo

Aqui tengo algo hecho mire si le sirve (requiere phpmailer)

index.php
(este es solo para que liste los archivos de una carpeta que serán los que se van a enviar)
Código PHP:
<?php 
$dir 
"para_enviar/"
$directorio=opendir($dir); 
echo 
"Archivos de la carpeta <b>'para_enviar'</b>"
echo 
"<br><br>"
while (
$archivo readdir($directorio)){ 
 if(
$archivo=='.' or $archivo=='..'){ 
 echo 
""
 }else { 
 
$enlace $dir.$archivo
 echo 
"<ul type='square'><li>"
 echo 
"<a href=form.php?enviar=$enlace >$archivo<br></a>"
 echo 
"</li></ul>"
 } 
 } 
closedir($directorio); 
?>

form.php

Código PHP:
<html>
<head>
<title>Form</title>
</head>
<body>
<form method="post" action="enviar.php">
<p>
<label>Nombre:</label> <br/> <input type="text" name="name" size="48" height="40"/>
</p>
<p>
<label>Email:</label> <br/> <input type="text" name="email" size="48" height="40"/>
</p>
<p>
<label>Archivo a enviar:</label> <br/> <input name="archivo" type="text" value="<?php echo $_GET['enviar']; ?>" size="48"    height="40"/>
</p>
<p>
<label>Sitio:</label>
<br/>
<textarea name="site" rows="2" cols="45" overflow:hidden>www.toro-valle.com</textarea>
</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>
<input type="submit" value="Enviar"/>
 <a href="form.html">Limpiar</a></p>
 </form>
 </body>
 </html>
enviar.php

Código PHP:
<?php
require("class.phpmailer.php");
include(
"email.php");
$name $_POST['name'];
$site $_POST['site'];
$archivo $_POST['archivo'];
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth true;
$mail->Host "localhost"// SMTP servers
$mail->Username "usuario";   // SMTP username
$mail->Password "contrasenia"// SMTP password
$mail->AddAddress($_POST['email']);
$mail->From     "[email protected]";
$mail->FromName "www.toro-valle.com";
$mail->Subject "mensaje de pagina de ejemplo";
$mail->IsHTML(true);
$mail->Body $message;
$mail->AddAttachment($archivo);
//$mail->AddAttachment("1.pdf");
if($mail->Send()) {
echo 
"mensaje enviado! Gracias! ";
print(
'<a href="index.php">Borrar y Volver</a>');

?>
mail.php

Código PHP:
<?php
$message 
'
<html>
<head>
<title>recomendacion www.toro-valle.com</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body>
<div align="center">
<p>
<table width="700" height="400" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#4A82BD">
<tbody>
<tr>
<td align="center" valign="middle">
<p>
<span class="ecxecxApple-style-span">
<b>
<font class="ecxecxApple-style-span" color="#ffffff">
<span class="Apple-style-span" style="font-size: 16pt; ">
Hola,</span>
</font>
</b>
</span>
</p>
<p>
<span class="ecxecxApple-style-span">
<b>
<font class="ecxecxApple-style-span" color="#ffffff">
<span class="Apple-style-span" style="font-size: 16pt; ">
 Esta es una exelente p&aacute;gina,
 </span>
 </font>
 </b>
 </span>
 </p>
<p>
<font color="#ffffff">
<span class="ecxecxApple-style-span" style="font-size:16pt">
<b>
<span class="Apple-style-span" style="font-size: 16pt; ">
Me gustar&iacute;a que le dieras una miradita.
</span>
&nbsp;
</b>
</span>
&nbsp;
</font>
</p>
<p>
<font class="Apple-style-span" color="#ffffff" size="3">
<span class="Apple-style-span" style="font-size: 11px;">
<br>
</span>
</font>
</p>
<p>
<font class="ecxecxApple-style-span" color="#ffffff">
<span class="ecxecxApple-style-span">
<span class="Apple-style-span" style="font-size: 8pt; ">
(Click en la Im&aacute;gen)
</span>
</span>
</font>
<br>
<a href="http://www.toro-valle.com">
<img src="http://www.toro-valle.com/imagenes/toro.png" width="550" border="0">
</a>
</p>
<p>
</p>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
'
?>
todos los archivos los puede encontrar aquí: http://www.box.net/shared/qzhsv91piq

Última edición por fredyossa; 28/02/2011 a las 13:22