sending attachments via mail(), possible?
| From: | Christian Dechery | Date: | Wed, 09 May 2001 19:10:02 +0000 |
| Subject: | sending attachments via mail(), possible? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-52162@lists.php.net to get a copy of this message | ||
Is it possible to send attachments via mail() function?
I tried it, and it didn't work out... the email I receive is all messed up, and even the simple text part of it is screwed up. I now very little about MIME, but I really need to send an attachment, any help? It's a text attachment...
This is the code I'm using:
function send_email($body,$num_pedido,$filename)
{
define(NL,"\n");
$boundary="test".chr(rand(65,91))."----".md5(uniqid(rand()));
$message="Segue em anexo dados referentes ao pedido $num_pedido.".NL.NL;
$message="Content-type: text/plain\nContent-transfer-encoding: 7bit".NL.NL.$message;
$attach="Content-type: text/plain\nContent-transfer-encoding: base64\nContent-disposition: attachment; filename=".$filename.NL.NL;
$attach.=base64_encode($body);
$attach.=NL;
$mail_body=$boundary.NL.$message.$boundary.NL.$attach.$boundary."-";
$header="MIME-Version: 1.0\nContent-Type: multipart/mixed;\n\tboundary=\"".$boundary."\"\nContent-Transfer-Encoding: 7bit";
// echo "<pre>$mail_body</pre>";
mail("christian@webstyle.com.br","CDYOU Pedido: ".$num_pedido,$mail_body,$header);
}
the headers are sent perfectly... and if I echo the $mail_body (I think) it's correct, but when I get the mail it's all screwed up...
thanks...
_________________________________
. Christian Dechery - CTO
.. WebDeveloper @ Webstyle!
.. http://www.webstyle.com.br
.. http://www.tanamesa.com.br