Re: PLEASE HELP...Email attachment corruption

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

 



Ron Herhuth wrote:
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@xxxxxxxxxxxx");

$toaddress = "testemail@xxxxxxxxxxxx";
$fromaddress = "Tatum CIO Tax <cio.tax@xxxxxxxxxxxx>";
$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@xxxxxxxxxxxx",$subject,$message,$headers);









If you're on a deadline I highly suggest grabbing PEAR's Mail_MIME package and using it instead of generating your own e-mails.


http://pear.php.net/package/Mail_MIME

--
paperCrane <Justin Patrin>

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


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux