Problem with mail() and attachment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I'm using the script below to send ascii files attached to mails via mail().
I'm running the script on different servers and it works fine. Now I got a
problem on windows server 2003. The attachment of the mail is disturbed, the
first 76 characters are missing, the rest of the attachment is correct. When
I looked at the mail headers of the mail I recieved I recognized that there
were some lines missing. Also the first line of the attachment part in the
header is mssing. As I use chunk_split without the chunklen paramter the
lines are all 76 characters long. So it just looks like that the server
ommits lines in the header. I marked the missing lines in the script with
comments. Has anybody got an idea where the problem could be?

Thank in advance

Stefan

  $unique_sep =md5(uniqid(time()))";
  $headers = "From: egrade questionaire\n";
  $headers .= "MIME-Version: 1.0\nContent-Type:
multipart/mixed;boundary=\"$unique_sep\";\n";

#The second \n at the end of the next command is ommited, the resulting
empty line is not in the header of the received mail
  $headers .= "charset=\"iso-8859-1\"\nContent-Transfer-Encoding:7bit\n\n";
  $headers .= "egrade-result\n";
  $headers .= "If you read this text your mail server is not supporting MIME
Format.\n";
  $headers .= "--$unique_sep\n";
  $headers .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n";
#The second \n at the end of the next command is ommited, the resulting
empty line is not in the header of the received mail
   $headers .= "Content-Transfer-Encoding: 7bit\n\n";
#From the next command only a single \n is  in the header of the received
mail, the text and the other \n are missing
  $headers .= "egrade-result\n\n";
  $headers .= "--$unique_sep\n";
# filename holds the path to the ascii file
  $headers .= "Content-Type: {text/plain}; name=\"{$filename}\"\n";
  $headers .= "Content-Transfer-Encoding: base64\n";
  $headers .= "Content-Disposition: attachment\n\n";
  $filedata = implode(file($filename), '');
  $headers .= chunk_split(base64_encode($filedata));
  $headers .= "--$unique_sep--\n";
  if(mail("sts@xxxxxxxxx","subject","egrade-result",$headers) or die("An
error occured! The questionnaire has not been processed"));

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux