[PHP] Truncating Lines

2001-10-25 Thread BT News

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]




Re: [PHP] Truncating Lines

2001-10-25 Thread DL Neil

Please define long, and perhaps think of that in the context of the RFC ?822 is it?
=dn

- Original Message - 
From: BT News [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: 25 October 2001 17:38
Subject: [PHP] Truncating Lines


 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]
 
 


-- 
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]




Re: [PHP] Truncating Lines

2001-10-25 Thread brett




  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.

hello,

you could use object buffering instead.

ob_start();
include 'your_page';
$body=ob_get_contents();
ob_end_clean();

This is how I send pages from my site in html to a mail address all the
time.

brett


-- 
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]