Hace unos dias publique un tema donde no podia adjuntar un archivo zip, el cual ya había solucionado.
Haciendo pruebas me tope con un gran problema.
Gmail me interpreta perfecto lo que envio, pero los demas proveedores de correo no.
Hotmail.- me manda el archivo zip sin ningún archivo dentro del mismo
Proveedor privado.- Me manda una cadena gigante pero no el archivo.
Esto es lo que tengo de mi envio de correo electronico, espero me puedan ayudar.
variables.
Código PHP:
$receptor=$_POST['receptor'];
$tempfolder="/temporal/";
$my_file = "archivo.zip";
$my_name = "administrador";
$my_mail = "[email protected]";
$my_subject = "prueba de correo adjunto";
$my_message = "Prueba de envío.";
mail_attachment($my_file, $tempfolder, $receptor, $my_mail, $my_name, $my_subject, $my_message);
Código PHP:
function mail_attachment($filename, $path, $mailto, $from_mail, $from_name, $subject, $message) {
$file = $path.$filename;
$content = chunk_split(base64_encode(file_get_contents($file)));
$uid= md5(uniqid(time()));
$bound="--".$uid."\r\n";
$last_bound="--".$uid."--\r\n";
$header = "From: ".$from_name." <".$from_mail.">\r\n";
$header .= "MIME-Version: 1.0"."\r\n";
$header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n";
$header .= "This is a multi-part message in MIME format.\r\n";
$header .= $bound;
$header .= "Content-type:text/plane; charset=utf-8\r\n";
$header .= "Content-Transfer-Encoding: 7bit\r\n";
$header .= $message."\r\n";
$header .= $bound;
$header .= "Content-Type: application/zip; name=\"".$file."\"\r\n";
$header .= "Content-Transfer-Encoding: base64\r\n";
$header .= "Content-Disposition: attachment; filename=\"".$filename."\"\r\n";
$header .= $content."\r\n";
$header .= $last_bound;
if (mail($mailto, $subject, "", $header)) {
echo "Correo enviado a ".$mailto;
} else {
echo "Error al enviar correo";
}
}
Código PHP:
function mail_attachment($filename, $path, $mailto, $from_mail, $from_name, $subject, $message) {
$file = $path.$filename;
$content = chunk_split(base64_encode(file_get_contents($file)));
$uid= md5(uniqid(time()));
$bound="--".$uid."\r\n";
$last_bound="--".$uid."--\r\n";
$header = "From: ".$from_name." <".$from_mail.">\r\n";
$header .= "MIME-Version: 1.0"."\r\n";
$header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n";
$header .= "This is a multi-part message in MIME format.\r\n";
$header .= $bound;
$header .= "Content-type:text/plane; charset=utf-8\r\n";
$header .= "Content-Transfer-Encoding: 7bit\r\n";
$cuerpo .= $message."\r\n";
$cuerpo .= $bound;
$cuerpo .= "Content-Type: application/zip; name=\"".$file."\"\r\n";
$cuerpo .= "Content-Transfer-Encoding: base64\r\n";
$cuerpo .= "Content-Disposition: attachment; filename=\"".$filename."\"\r\n";
$cuerpo .= $content."\r\n";
$cuerpo .= $last_bound;
if (mail($mailto, $subject, $cuerpo, $header)) {
echo "Correo enviado a ".$mailto;
} else {
echo "Error al enviar correo";
}
}




