views:

23

answers:

0

I run PHP on IIS6. I have some PHP that successfully sends a 1KB image as an attachment on an email. When I try and attach a 500KB PDF however (having changed the Content-Type), it hangs and after a few minutes I get "FastCGI process exceeded configured request timeout" (Error Number 258 (0x80070102)).

Any thoughts on why it's taking so long to attach the PDF? The solution is not to increase the timeout limit, I can't have users sitting there for 3+ minutes while the file gets sent.

I've included my code below:

    $headers   = "From: ".$from."\r\n";
    $headers .= "Reply-To: ".$from."\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n"; 
    $headers .="This is a multipart message in MIME format. \r\n\r\n";

    $headers .= "--".$uid."\r\n\r\n";
    $headers .= "Content-Type: text/plain; charset-iso-8859-1\r\n";
    $headers .= "Content-Transfer-Encoding: quoted-printable\r\n\r\n";
    $headers .= $text . "\r\n\r\n";

    $headers .= "--".$uid."\r\n\r\n";
    $headers .= "Content-Type: text/html; charset-iso-8859-1\r\n";
    $headers .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
    $headers .= $html  . "\r\n\r\n";

    $headers .= "--".$uid."\r\n\r\n";
    $headers .= "Content-Type: image/png; name=\"".$filename."\"\r\n";
    $headers .= "Content-Transfer-Encoding: base64\r\n";
    $headers .= "Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n";
    $attachment = chunk_split(base64_encode(file_get_contents($path.$filename))); 
    $headers .= $attachment . "\r\n\r\n";

    $headers .= "--".$uid."\r\n\r\n";

    //send the email 
    $mail_sent = @mail( $to, $subject, $text, $headers );

Thanks in advance for any advice.