![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
12/12/2007, 19:07
|
![Avatar de Sergestux](http://static.forosdelweb.com/customavatars/avatar192322_7.gif) | | | Fecha de Ingreso: agosto-2007 Ubicación: Tapachula
Mensajes: 1.218
Antigüedad: 17 años, 5 meses Puntos: 20 | |
Re: Script archivo adjunto Código PHP: function EnviarCorreo($Archivo, $Mensaje='Correo enviado automaticamente', $Asunto="Ninguno", $Para='[email protected]', $De='[email protected]') { $DirLocal='/archivos/';
$buffer = implode("", file("$DirLocal$Archivo")); // Leer fichero $buffer=chunk_split(base64_encode($buffer)); // Codificación en base64 y divido // Cabeceras $Cabecera = "From: $De\n"; $Cabecera .= "Return-Path: <$From>\n"; $Cabecera .= "Return-Receipt-To: <$From>\n"; //Notificar de leido $Cabecera .= "MIME-version: 1.0\n"; $Cabecera .= "Content-type: multipart/mixed; "; //$Cabecera .= "Content-type: multipart/HTML/mixed/text; "; $Cabecera .= "boundary=\"Message-Boundary\"\n"; $Cabecera .= "Content-transfer-encoding: 7BIT\n"; $Cabecera .= "X-attachments: $DirLocal$Archivo\n\n";
// Adjuntar el fichero $Msj = "\n\n--Message-Boundary\n"; $Msj .= "Content-type: Binary; name='$Archivo'\n"; $Msj .= "Content-Transfer-Encoding: BASE64\n"; $Msj .= "Content-disposition: attachment; filename=$Archivo\n\n"; $Msj .= "$buffer\n";
// Mensaje en html $Msj .= "\n\n--Message-Boundary\n"; $Msj .= "Content-Type: text/HTML; charset=ISO-8859-1\n"; $Msj .= "Content-Transfer-Encoding: 8bit\n\n"; $Cadena=CrearHtmlMinuta($Cadena, $Asunto); //Lo convierto a pagina html $Msj .= $Cadena;
$Msj .= "\n\n--Message-Boundary\n"; $Msj .= "Content-type: text/plain; charset=iso-8859-1\n"; $Msj .= "Content-transfer-encoding: 7BIT\n"; $Msj .= "Content-description: Mail message body\n\n"; $Msj .= "$Mensaje\n"; //Agrego el contenido del mensaje $Error=mail("$Para", $Asunto, $Msj, $Cabecera); if (!$Error) // Envio de mail y regreso el estado del envio return true; else return $Error; }
|