Re: PLEASE HELP...Email attachment corruption
| From: | DvDmanDT | Date: | Thu, 25 Mar 2004 19:13:22 +0000 |
| Subject: | Re: PLEASE HELP...Email attachment corruption | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-23276@lists.php.net to get a copy of this message | ||
Maybe the files are damaged even before they get to the php script?
--
// DvDmanDT
MSN: dvdmandt¤hotmail.com
Mail: dvdmandt¤telia.com
"Ron Herhuth" <Ron.Herhuth@tatumpartners.com> skrev i meddelandet
news:d8e401c4126b$2eaf5660$f25d2981@tatumlink.com...
I am dying here. I'm on a deadline and I can't get
attachments...specifically PDFs and Word Docs to send without corruption.
I am using the script below to send the emails, and I have used several of
the classes on PHP.classes to try but everytime the files show up and the
error reads "The File is damaged and could not be repaired" when they are
opened. When I print the message out to the browser it appears as though
the entire string is not being sent. Is there any ini settings that might
affect this? I am really in a bind and don't know what to do. Any
suggestions would be greatly appreciated.
SCRIPT:
ini_set("sendmail_from","cio.tax@tatumcio.com");
$toaddress = "testemail@tatumcio.com";
$fromaddress = "Tatum CIO Tax <cio.tax@tatumcio.com>";
$subject = "Tatum CIO K-1 & State Tax Information";
$headers = "From: $fromaddress\n";
$headers .= "Reply-To: $fromaddress\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"MIME_BOUNDARY\"\n";
$headers .= "X-Sender: $fromaddress\n";
$headers .= "X-Mailer: PHP4\n";
$headers .= "X-Priority: 3\n";
$headers .= "Return-Path: $fromaddress\n";
$headers .= "This is a multi-part message in MIME format.\n";
$message = "--MIME_BOUNDARY\n";
$message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n";
$message .= "Content-Transfer-Encoding: quoted-printable\n\n";
$message .= "\n\n";
// email text message goes here
$message .= "
\n
Attached to this email are the following 3 documents: to you from the
Tatum CIO Tax
\n\n
";
$message .= "\n";
$message .= "--MIME_BOUNDARY\n";
// FILE ATTACHMENT CODE
$file_url = "Simpletest.pdf";
$fp = fopen($file_url,"r");
$str = fread($fp, filesize($file_url));
$str = chunk_split(base64_encode(implode("", file("Simpletest.pdf")))); ;
$message .= "Content-Type: application/pdf; name=\"Simpletest.pdf\"\n";
$message .= "Content-disposition: attachment\n";
$message .= "Content-Transfer-Encoding: base64\n";
$message .= "\n";
$message .= "$str\n";
$message .= "\n";
$message .= "--MIME_BOUNDRY\n";
$message .= "--MIME_BOUNDRY--\n";
// echo "TO: $toaddress <br><br>SUBJECT: $subject<br><br>MESSAGE:
$message<br><br><br><br>";
mail("ron@tatumcfo.com",$subject,$message,$headers);