Re: mail()
| From: | Daniel Convissor | Date: | Mon, 24 Jul 2000 15:54:30 +0000 |
| Subject: | Re: mail() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-7920@lists.php.net to get a copy of this message | ||
Hey Christian:
> Can someone tell me how to add attachments to mail.
Sure, check out the code below.
--Dan
--
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
More than just answers. Solutions. (SM)
http://www.analysisandsolutions.com/
4015 7 Av #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409
# Here, make up some string of characters and numbers that suit your needs.
# Should be unique...
$Boundary = ........;
$AddHead .= "Content-Type: multipart/mixed; ";
$AddHead .= "boundary=\"------------$Boundary\"\n";
$Body = "This is a multi-part message in MIME format.\n";
$Body .= "--------------$Boundary\n";
$Body .= "Content-Type: text/plain; charset=us-ascii\n";
$Body .= "Content-Transfer-Encoding: 7bit\n\n";
# .... create the text you want...
$Body .= "--------------$Boundary\n";
$Body .= "Content-Type: application/zip; name=\"Item$Key.zip\"\n";
$Body .= "Content-Transfer-Encoding: $Encoding\n";
$Body .= "Content-Disposition: inline; filename=\"Item$Key.zip\"\n\n";
# You can use this to include an existing file.
while ( $Temp = fgets($AttachHandle, 500) ) {
$Body .= "$Temp";
}
# Or you can create your own code or message here.
$Body .= "\n--------------$Boundary--";
mail("$Email", "Your Subject", "$Body", "$AddHead\n");