Reply to Re: [PHP] Attaching a PDF in email (no body text displays)

Your name:

Reply:


Posted by James Benson on 07/21/05 20:01

Personally I use the MimeMail class, that works a treat,

http://www.phpguru.org/static/mime.mail.html


Their are two versions, one php4 one php5, or install via pear.




JB



Ade Smith wrote:
> I am attaching a PDF document to an email, this part works great, however to
> get this to work it prevents the text in the body of the message to be
> displayed, what am I doing wrong?
>
>
>
> Here is the code:
>
>
>
> $filename = "confirmation.pdf";
>
> if(!($fp = fopen($filename, "r"))):
>
> $error = "Can't open file";
>
> echo $error;
>
> exit;
>
> endif;
>
>
>
> $boundary = "b" . md5(uniqid(time()));
>
> $boundary='"'.$boundary.'"';
>
>
>
> $attach = fread($fp, filesize($filename));
>
> $attach = chunk_split(base64_encode($attach));
>
>
>
> $mime = "from: pdf@goldcrownresort.com\n";
>
> $mime .= "Content-type: multipart/mixed; boundary=$boundary";
>
>
>
> $mime .= "--$boundary\r\n";
>
> $mime .= "Content-type: application/pdf; name=\"confirmation.pdf\"\r\n";
>
> $mime .= "Content-Transfer-Encoding: base64\r\n\r\n";
>
> $mime .= "Content-Disposition: attachment;\r\n";
>
> $mime .= " \r\n$attach\n";
>
>
>
> $mime .= "--$boundary\r\n";
>
> $mime .= "Content-Type: text/HTML; charset=iso-8859-1\r\n";
>
> $mime .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
>
> $mime .= "test test test";
>
> $mime .= "--$boundary--\r\n";
>
>
>
> mail("user@domain.com","Your Confirmation: $confirmation_number","",$mime);
>
>
>
>
>
>
>
>
>
>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация