Subject: Bug in IMAP function's library : "imap_header"

From: Vikas Aggarwal <[email-masked]>
Date: Fri, 15 Feb 2002 04:09:33 +0500

Hi, 

There is a bug (seems to be) in one of the function's library. 
The function is "imap_header". 

The bug is that if a mail is sent using Eudora or from Outlook Express, 
and you have only mentioned the email-id's in BCC field, the mail that is 
stored in the mail file, has following format 
################ 
To: <Undisclosed-Recipient:;@vd1.vsnl.net.in;> 
Subject: Fw:Newsletter 
Date: Sat, 2 Feb 2002 22:17:37 +0530 
################ 

On using the web-based interface for displaying mails, the function 
"imap_header" is used to read to read one mail at a time and show 
information. 

But if any mail has above header, the function starts displaying the warning 
################## 
Warning: Unterminated mailbox: [email-masked] 
(errflg=3) in Unknown on line 0 

Warning: Unexpected characters at end of address: :;@vd1.vsnl.net.in;> 
(errflg=3) in Unknown on line 0 
##################### 

I am using the function as 
############## 
for ($i = $begin, $j = $beginIndex; $i <= $end; $i++, $j++) { 
$msgnum = $sorted[$i-1]; 
$h = @imap_header($imp->stream, imap_msgno($imp->stream, $msgnum)); 
... and further 
} 
############## 

I asked the same problem on php.net site and the final answer that i got 
says that the -> imap <- library generates this warning and that there 
is -> nothing <- PHP can do about it. This has to be fixed in the imap 
library. 
You can see the conversation at http://bugs.php.net/bug.php?id=15536 

Hope if i can get any sort of help in this regard. 
Otherwise, is there any work around to atleast stop warning to appear!!

Thanks in advance. 
Vikas Aggarwal

---

From: Mark Crispin <[email-masked]>
Date: Thu, 14 Feb 2002 20:25:03 -0800 (PST)

> The function is "imap_header".

There is no such function in the c-client library.  That must be a PHP
function.

I don't know if PHP is calling any c-client imap_???() functions directly,
but if it is, then it is very broken.  All c-client imap_???() functions
are internal to c-client and must not be calle dexternally.

> stored in the mail file, has following format

This To: header has invalid syntax according to both RFC 822 and RFC 2822.
I am fairly confident that neither Eudora nor Outlook express generate
such a bogus header.  They probably generated
	To: Undisclosed Recipient: ;
which is valid according to RFC 822 and RFC 2822.  So, some other program,
probably the mail transmission agent or mail delivery agent, damaged this
header.

> But if any mail has above header, the function starts displaying the warning

If you check the c-client documentation, you will find that errflg=3 is an
RFC [2]822 parse error.

> is -> nothing <- PHP can do about it. This has to be fixed in the imap

There is nothing to fix in the c-client library.

This is a legitimate diagnostic of invalid RFC [2]822 syntax.  It is
labelled as such.  The application is free to disregard mm_log() events
with errflg=3 if it desires.  All events with errflg=3 are that class of
message header parsing error.

> Otherwise, is there any work around to atleast stop warning to appear!!

It all depends upon what is displaying those warnings.

c-client displays nothing.  The display is being done by something outside
of c-client, and c-client gave it the information to know what type of
event it was.

If your application is displaying mm_log() events with no way to suppress
them even if errflg=3, then this is a bug in your application and it's
your bug to fix.

If PHP is displaying mm_log() events with no way to suppress them even if
errflg=3, then this is a bug in PHP and it's the PHP maintainers' bug to
fix.

-- Mark --

http://staff.washington.edu/mrc
Science does not emerge from voting, party politics, or public debate.