Truncating Lines
| From: | BT News | Date: | Thu, 25 Oct 2001 16:38:19 +0000 |
| Subject: | Truncating Lines | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-72302@lists.php.net to get a copy of this message | ||
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.