Estoy tratando de que php adjunte un archivo zip o un pdf que ya tengo guardado en mi servidor con la funcion mail().
Pero no puedo
![Negando](http://static.forosdelweb.com/fdwtheme/images/smilies/negar.gif)
![Negando](http://static.forosdelweb.com/fdwtheme/images/smilies/negar.gif)
Y cuanto mando un PDF este llega vacío.
Esto es lo que tengo (lo copie de otra pagina y lo modifique un poco)
Código PHP:
$my_file = $nomDoc.".zip";
$my_path="./Temp/";
$my_name = "Prueba";
$my_mail = "[email protected]";
$my_subject = "Se envia archivo de prueba.";
$my_message = "Esta es una prueba de envio de correo adjunto.";
mail_attachment($my_file, $my_path, "[email protected]", $my_mail, $my_name, $my_subject, $my_message);
function mail_attachment($filename, $path, $mailto, $from_mail, $from_name, $subject, $message) {
$file = $path.$filename;
$file_size = filesize($file);
$handle = fopen($file, "r");
$content = fread($file, $file_size);
fclose($handle);
$content = chunk_split(base64_encode(file_get_contents($filename)));
$uid = md5(uniqid(time()));
$name = basename($file);
$header = "From: ".$from_name." <".$from_mail.">";
$header .= "MIME-Version: 1.0";
$header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"";
$header .= "This is a multi-part message in MIME format.";
$header .= "--".$uid."";
$header .= "Content-type:text/plain; charset=iso-8859-1";
$header .= "Content-Transfer-Encoding: 7bit";
$header .= $message."";
$header .= "--".$uid."";
$header .= "Content-Type: application/octet-stream; name=\"".$filename."\"";
$header .= "Content-Transfer-Encoding: base64";
$header .= "Content-Disposition: attachment; filename=\"".$filename."\"";
$header .= $content."";
mail($mailto, $subject, "", $header)
}
![Neurótico](http://static.forosdelweb.com/fdwtheme/images/smilies/scared.png)
![Neurótico](http://static.forosdelweb.com/fdwtheme/images/smilies/scared.png)
![Neurótico](http://static.forosdelweb.com/fdwtheme/images/smilies/scared.png)
Gracias ante todo.