Reply
Emailing Zips!!!
Old 10-25-2004, 05:20 PM Emailing Zips!!!
ACJavascript's Avatar
Humble Mod

Posts: 548
Location: CT, USA
Hello,

Heres my problem. I would like to send a ZIP file as an attachment in a php email using the mail() function.

The attachment seems to work but when you download the zip it says its corrupted.

Any ideas??

Heres the code so far:
PHP Code:
<?php 


$to
="email1"
$from="email2"
$subject="Test"
$message="TESTING!"

$headers "From: $from"

  
// Generate a boundary string 
  
$semi_rand md5(time()); 
  
$mime_boundary "==Multipart_Boundary_x{$semi_rand}x"
   
    
// Add the headers for a file attachment 
  
$headers .= "\nMIME-Version: 1.0\n" 
              
"Content-Type: multipart/mixed;\n" 
              
" boundary=\"{$mime_boundary}\""
               
                
// Add a multipart boundary above the plain message 
  
$message "This is a multi-part message in MIME format.\n\n" 
             
"--{$mime_boundary}\n" 
             
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" 
             
"Content-Transfer-Encoding: 7bit\n\n" 
             
$message "\n\n"

  
// Add file attachment to the message 
  
$message .= "--{$mime_boundary}\n" 
              
"Content-Type: application/x-zip-compressed;\n" 
              
" name=\"test.zip\"\n" 
              
"Content-Disposition: attachment;\n" 
              
" filename=\"test.zip\"\n" 
              
"Content-Transfer-Encoding: base64\n\n\n\n" 
              
"--{$mime_boundary}--\n"

              
// Send the message 
$ok = @mail($to$subject$message$headers); 
if (
$ok) { 
  echo 
"<p>Mail sent!</p>"
} else { 
  echo 
"<p>Mail could not be sent. Sorry!</p>"

?>
sorry for the sloppy code
__________________
CYTech-services.com - 100 Satisfied Customers - Custom Programming and Web Development
ACJavascript is offline
Reply With Quote
View Public Profile Visit ACJavascript's homepage!
 
When You Register, These Ads Go Away!
Reply     « Reply to Emailing Zips!!!
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.10836 seconds with 12 queries