Hi.

I have a script which sends mails with PDF attachments - works fine for hotmail and everything else my clients use but NOT googlemail - whole thing ends up in a "noname" attachment.

here's the part of the script:



$random_hash = md5(date('r', time()));
$headers = "From: thingy@wosit.co.uk\nReply-To: thingy@wosit.co.uk\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";
$attachment = chunk_split(base64_encode(file_get_contents('../ebooks/book.pdf')));

ob_start();
?>
--PHP-mixed-<?php echo $random_hash; ?>
Content-Type: multipart/alternative; boundary="PHP-alt-<?php echo $random_hash; ?>"

--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Hello - Thankyou for your order.

--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

<p><h2>Hi <?php echo $bod; ?>!<br/>Thankyou for your order!</h2>
Please find you new <b>eBook</b> attached.</p>

--PHP-alt-<?php echo $random_hash; ?>--

--PHP-mixed-<?php echo $random_hash; ?>
Content-Type: application/pdf; name="book.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment

<?php echo $attachment; ?>
--PHP-mixed-<?php echo $random_hash; ?>--

<?php
$message = ob_get_clean();
$mail_sent = @mail( $to, $subject, $message, $headers );

if($mail_sent) { etc etc


Would be very grateful for any help!
(or maybe I should chuck in manually sorting MIME and just use PEAR....)