adjuntar un archivo en un mail php
Publicado por marcelo (1 intervención) el 11/06/2007 05:27:05
hola, tengo un problema, no se pq no puedo adjuntar unos archivos que pongo en un formulario el cual se manda por mail, saque el codigo para adjuntar un archivo de esta pagina http://www.hollowearth.co.uk/tech/php/email_attachments.php
aki va el codigo k puse yo:
<body>
<?php
$mime_boundary = "<<<--==+X[".md5(time())."]";
$headers .= "From: $_POST[mailper]\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: multipart/mixed;\r\n";
$headers .= " boundary=\"".$mime_boundary."\"";
$message .= "This is a multi-part message in MIME format.\r\n";
$message .= "\r\n";
$message .= "--".$mime_boundary."\r\n";
$message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n";
$message .= "Content-Transfer-Encoding: 7bit\r\n";
$message .= "\r\n";
$message .= "--".$mime_boundary."\r\n";
$message .= "Content-Type: application/octet-stream;\r\n";
$message .= " name=\"$_POST[filelogo]\"\r\n";
$message .= " name=\"$_POST[filefoto]\"\r\n";
$message .= "Content-Transfer-Encoding: quoted-printable\r\n";
$message .= "Content-Disposition: attachment;\r\n";
$message .= " filename=\"$_POST[filelogo]\"\r\n";
$message .= " filename=\"$_POST[filefoto]\"\r\n";
$message .= "\r\n";
$message .= $fileContent;
$message .= "\r\n";
$message .= "--".$mime_boundary."\r\n";
if(mail("[email protected]","Nuevo anuncio $_POST[nomneg] $_POST[tiponeg]","$message","From: $_POST[mailper] $headers"))
?>
filelogo, y filefoto son los nombres de los campos de archivos, y el formulario se iso con method="post"
ojala me puedan ayudar, de antemano gracias
aki va el codigo k puse yo:
<body>
<?php
$mime_boundary = "<<<--==+X[".md5(time())."]";
$headers .= "From: $_POST[mailper]\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: multipart/mixed;\r\n";
$headers .= " boundary=\"".$mime_boundary."\"";
$message .= "This is a multi-part message in MIME format.\r\n";
$message .= "\r\n";
$message .= "--".$mime_boundary."\r\n";
$message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n";
$message .= "Content-Transfer-Encoding: 7bit\r\n";
$message .= "\r\n";
$message .= "--".$mime_boundary."\r\n";
$message .= "Content-Type: application/octet-stream;\r\n";
$message .= " name=\"$_POST[filelogo]\"\r\n";
$message .= " name=\"$_POST[filefoto]\"\r\n";
$message .= "Content-Transfer-Encoding: quoted-printable\r\n";
$message .= "Content-Disposition: attachment;\r\n";
$message .= " filename=\"$_POST[filelogo]\"\r\n";
$message .= " filename=\"$_POST[filefoto]\"\r\n";
$message .= "\r\n";
$message .= $fileContent;
$message .= "\r\n";
$message .= "--".$mime_boundary."\r\n";
if(mail("[email protected]","Nuevo anuncio $_POST[nomneg] $_POST[tiponeg]","$message","From: $_POST[mailper] $headers"))
?>
filelogo, y filefoto son los nombres de los campos de archivos, y el formulario se iso con method="post"
ojala me puedan ayudar, de antemano gracias
Valora esta pregunta


0