Re: Truncating Lines
| From: | Mike Frazer | Date: | Thu, 25 Oct 2001 17:26:46 +0000 |
| Subject: | Re: Truncating Lines | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-72311@lists.php.net to get a copy of this message | ||
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" <hostmaster@wirestation.com> wrote in message
news:20011025163915.27429.qmail@pb1.pair.com...
> 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.
>
>
>
>