View Single Post
  #2 (permalink)  
Old June 2nd, 2008, 03:24 PM
philip_cole philip_cole is offline
Friend of Wrox
Points: 894, Level: 11
Points: 894, Level: 11 Points: 894, Level: 11 Points: 894, Level: 11
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2005
Location: London, , United Kingdom.
Posts: 166
Thanks: 2
Thanked 33 Times in 33 Posts
Default

It looks like you have gone over the top with the line breaks and some of your headers are running onto two lines, e.g. in the file attachment headers. You can out breaks in the lines to make the code readable, but I think you need to delete some \ns. Try this:



// Add the headers for a file attachment
$headers .= "\nMIME-Version: 1.0\n" .
            "Content-Type: multipart/mixed;" .
            " 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";

// Base64 encode the file data
$data = chunk_split(base64_encode($data));

// Add file attachment to the message
$message .= "--{$mime_boundary}\n" .
            "Content-Type: {$fileatt_type}; name=\"{$fileatt_name}\"\n" .
            //"Content-Disposition: attachment; filename=\"{$fileatt_name}\"" .
            "Content-Transfer-Encoding: base64\n\n" .
            $data . "\n\n" .
            "--{$mime_boundary}--\n";