To build this extension, grab ftp://ftp.cac.washington.edu/imap/imap-4.2.tar.Z
and build the library.  Then copy c-client/c-client.a to /usr/local/lib 
or some other directory on your link path and copy c-client/rfc822.h, mail.h 
and linkage.h to /usr/local/include.  Then type: make imap.so from the 
php3/dl directory. 

If you are compling with the imap4r1 lib define IMAP41.

Function list:

--  imap_open
Description: opens a IMAP_stream to a mailbox
int imap_open(string mailbox, string username, string password,int options);
The last parameter, options, is optional.
if you put in a "1" for the last parameter, it opens up the mailbox read-only.
Returns: IMAP_stream

--  imap_reopen
Description: re-opens a IMAP_stream to a new mailbox
int imap_reopen(IMAP_stream mbox
			, string mailbox, string username, string password);
Returns: True if sucessful False otherwise.

--  imap_close
Description: Closes a IMAP_stream.
int imap_close(IMAP_stream mbox);
Returns: True if sucessful False otherwise.

--  imap_check
Description: Checks current mailbox.
array imap_check(IMAP_stream mbox);
Returns: This function returns an object.  The propertys are 
"Date", "Driver", "Mailbox", "Nmsgs", and "Recent".

--  imap_num_msg
int imap_num_msg(IMAP_stream mbox);
Returns: number of messages in current mailbox.

--  imap_headers
array imap_headers(IMAP_stream mbox);
Returns: An array of strings formated with header info. One element per mail msg

--  imap_header
array imap_header(IMAP_stream mbox,long msgno);
Returns: This function returns an associative array. The elements are
"Date", "From", "From2", "Subject", "To", "cc", "ReplyTo", "Recent",
"Unseen", "Flagged", "Answered", "Deleted", "Msgno", "MailDate", and "Size".

--  imap_headerinfo - alias for imap_header
array imap_headerinfo(IMAP_stream mbox,long msgno,int fromlength,int subjectlength,string defaulthost);
defaulthost is the hostname to put at the end of an address if it does not contain a hostname.
NEW: returns the following objects:

remail,date,Date,subject,Subject,in_reply_to,message_id,newsgroups,
followup_to,references,

toaddress (full email address)

to[] (returns an array of objects from the To line, containing:)
   personal
   adl
   mailbox
   host

fromaddress 

from[] (returns an array of objects from the From line, containing:)
   personal
   adl
   mailbox
   host

ccaddress
cc[] (returns an array of objects from the Cc line, containing:)
   personal
   adl
   mailbox
   host

bccaddress
bcc[] (returns an array of objects from the Bcc line, containing:)
   personal
   adl
   mailbox
   host

reply_toaddress
reply_to[] (returns an array of objects from the Reply_to line, containing:)
   personal
   adl
   mailbox
   host

senderaddress
sender[] (returns an array of objects from the sender line, containing:)
   personal
   adl
   mailbox
   host

return_path
return_path[] (returns an array of objects from the return_path line, containing:)
   personal
   adl
   mailbox
   host

udate ( mail message date in unix time)

fetchfrom (from line formatted to fit FROMLENGTH characters)
fetchsubject (subject line formatted to fit SUBJECTLENGTH characters)

--  imap_body
string imap_body(IMAP_stream mbox,long msgno);
Returns: This function returns the body of the email msg.

--  imap_expunge
Description: This function removes and msg marked with imap_delete.
int imap_expunge(IMAP_stream mbox); 
Returns: True if sucessful False otherwise.

--  imap_delete
Description: Flags a message for deleation.  Actual deleation done by imap_expunge
int imap_delete(IMAP_stream mbox,long msgno);
Returns: True if sucessful False otherwise.

--  imap_undelete
Description: Removes deleation flag.
int imap_undelete(IMAP_stream mbox,long msgno);
Returns: True if sucessful False otherwise.

--  imap_mail_copy
Description: copies a mail msg from current mailbox to new mailbox.
int imap_mail_copy(IMAP_stream mbox, string new_box, string msglist);
Returns: True if sucessful False otherwise.
Note: msglist is a range not just message numbers. See imap doc.

--  imap_mail_move
Description: moves a mail msg from current mailbox to new mailbox.
int imap_mail_moves(IMAP_stream mbox, string new_box, string msglist);
Returns: True if sucessful False otherwise.
Note: msglist is a range not just message numbers. See imap doc.

--  imap_createmailbox
Description: creates a new mailb called newmbox.
int imap_createmailbox(IMAP_stream mbox, string newmbox);
Returns: True if sucessful False otherwise.

--  imap_renamemailbox
Description: rename old mailbox to new mailbox.
int imap_renamemailbox(IMAP_stream mbox, string oldmbox, string newmbox);
Returns: True if sucessful False otherwise.

--  imap_deletemailbox
Description: deleates a mailbox called oldbox.
int imap_deletemailbox(IMAP_stream mbox, string oldbox);
Returns: True if sucessful False otherwise.

--  imap_listmailbox
array imap_listmailbox(int imap_stream, string mailbox, string pattern);
Returns: Array of strings that have the mailbox names.
Here is a sample program

Here are some new function.
added by 
/--------------------------------------------------------------------\
| Kaj-Michael Lang        | WWW:    http://www.tal.org               |
| Kaskentie 5 C9          | E-Mail: milang@tal.org                   |
| 20720 Turku             |         milang@onion.sip.fi              |
| FINLAND                 |         milang@infa.abo.fi               |
|-------------------------|         klang@abo.fi                     |
| GSM: +358-(0)40-5271058 | FTP:    ftp://ftp.tal.org                |
\--------------------------------------------------------------------/

--  imap_listsubscribed()
    List all the mailboxes that you have subscribed
--  imap_subscribe()
    Subscribes to a mailbox
--  imap_unsubscribe()
    Unsubscribes from a mailbox
--  imap_scanmailbox()
    Almost the same as imap_listmailbox but uses a string to search for in
    the mailboxes
--  imap_num_recent()
    Gives the numbers of recent messages in the mailbox. Almost the same as
    imap_num_msg

-------contributions by Antoni Pamies Olive toni@readysoft.net  ----------
-- imap_fetchstructure(IMAP_stream mbox,long msgno)
     This function causes a fetch of all the structured information
     (envelope, internal date, RFC 822 size, flags, and body structure) for
     the given msgno.
     The returned values is an object. The properties of this object are:
     type,encoding,ifsubtype,subtype,ifdescription,description,ifid,id,
     lines,bytes,ifparameters
     It also returns an array of objects called parameters[]. This object has
     the following properties:
      attribute,value
    in the case of multipart, it also returns an array of objects of all of the above
    properties, called parts[].
      
-- imap_append(IMAP_stream mbox,string folder, string message)
   puts the given string message into the given mailbox.
   
-- imap_ping(IMAP_stream mbox)
     The function pings the stream to see if it is still active.  It may
     discover new mail; this is the preferred method for a periodic "new mail
     check" as well as a "keep alive" for servers which have an inactivity
     timeout.  It returns not NIL if the stream is still alive, NIL otherwise.

-- imap_fetchbody(IMAP_stream mbox,long msgno,long part)
     This function causes a fetch of the particular section of the
     body of the specified message as a text string and returns that text
     string.  The section specification is a string of integers delimited by
     period which index into a body part list as per the IMAP4
     specification.  Body parts are not decoded by this function.

-------------------------------------------------------------------

-----Contributions by Mark Musone musone@afterfive.com --------

-- imap_base64(string text)
      This function decodes a BASE64 body part given a source string.  
      The decoded body part as a string is returned. NOTE, unlike the
      base64_decode function in the standard php functions, this is
      binary string safe. This also uses the built in c-client base64
      decoding, not an internal routine, so you must still load the imap.so
      library to use this.


--imap_rfc822_write_address(string mailbox,string host, string personal)
Returns a properly formatted email address given the mailbox, host, and personal info.

--imap_rfc822_parse_adrlist(string email_address,string default_host)

Returns 3 objects given the input strings:
mailbox - the mailbox name (username)
host   - the host name
personal - the personal name

-----Contributions by Brian Wang brian@vividnet.com

-- imap_8bit(string TEXT)
This function returns a quoted-printable string given an 8bit
source string.

--imap_qprint(string TEXT)
This function returns a string given a quoted-printable source string.
The decoded body part as an 8-bit character string is returned.














