Try the following:

$body = join('', file("somefile.html"));

That one line of code will help you avoid the idea of a buffer; it reads
clear through to the newline and splits it there, dumping each line into an
element of an array.  join() just puts it all into one single variable for
output.

Mike Frazer




"Bt News" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi,
>
> I have the following code, which reads in an html file
>
> $fd = fopen("somefile.html", "r");
> while (!feof($fd)) {
>   $buffer = fgets($fd, 4096);
>   $body .= $buffer;
> }
> fclose($fd);
>
> I am then mailing this:
>
>  if (mail($username." <".$email.">", $mailsubject, $body, "From:
> ".$Fromname." <".$Fromaddress.">\nContent-Type: text/html;
> charset=iso-8859-1
> "))
>
> All works fine, except when a particular line in the html file is
unusually
> long. Where this is the case, the mail gets sent but the long line
truncates
> (the last character on the line being ! (exclamation mark)) followed by
the
> remainder of the line on a new line. This obviously causes problems when
> trying to display the HTML.
>
> Strangely though, if the recipient of the mail is a local user (i.e. a
user
> residing on this box), the line does not truncate and the HTML source
> remains intact. Equally, if I write out the contents of $body to the
screen,
> the HTML source is intact.
>
> I suspect Sendmail may be the culprit, but I'm not sure.
>
> I realise I could keep my HTML source lines to a certain length, however
> these are often created dynamically so it's not that straight forward.
>
>
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to