Class sieve

Description

SIEVE class - A Class that implements MANAGESIEVE in PHP4|5.

This program provides a handy interface into the Cyrus timsieved server under php4. It is tested with Sieve server included in Cyrus 2.0, but it has been upgraded (not tested) to work with older Sieve server versions.

All functions will return either true or false and will fill in $sieve->error with a defined error code like EC_QUOTA, raw server errors in $sieve->error_raw, and successful responses in $sieve->responses.

NOTE: a major change since version (0.0.5) is the inclusion of a standard method to retrieve server responses. All functions will return either true or false and will fill in $sieve->error with a defined error code like EC_QUOTA, raw server errors in $sieve->error_raw, and successful responses in $sieve->responses.

Usage is pretty simple. The basics is login, do what you need and logout. There are two sample files (which suck) test.php and testsieve.php. test.php allows you to create/delete/view scripts and testsieve.php is a very basic sieve server test.

Please let us know of any bugs, problems or ideas at sieve-php development list: sieve-php-devel@lists.sourceforge.net. A web interface to subscribe to this list is available at: https://lists.sourceforge.net/mailman/listinfo/sieve-php-devel

Located in /sieve-php.lib.php (line 76)


	
			
Variable Summary
 mixed $auth_in_use
 mixed $auth_types
 mixed $error
 mixed $error_raw
 mixed $fh
 mixed $fp
 mixed $host
 mixed $len
 mixed $line
 mixed $loggedin
 mixed $pass
 mixed $port
 mixed $responses
 mixed $retval
 mixed $script
 mixed $tmpfile
 mixed $user
Method Summary
 sieve sieve ($host $host, $port $port, $user $user, $pass $pass, [$auth $auth = ""], [$auth_types $auth_types = 'PLAIN'])
 void authenticate ()
 void get_response ()
 array parse_for_quotes ($string $string)
 boolean sieve_alive ()
 mixed sieve_deletescript ($scriptname $scriptname)
 arr sieve_getscript ($scriptname $scriptname)
 boolean sieve_havespace ($scriptname $scriptname, $scriptsize $scriptsize)
 boolean sieve_listscripts ()
 boolean sieve_login ()
 boolean sieve_logout ()
 boolean sieve_sendscript ($scriptname $scriptname, $script $script)
 boolean sieve_setactivescript ($scriptname $scriptname)
 void status ($string $string)
Variables
mixed $auth_in_use (line 88)

type of authentication attempted

mixed $auth_types (line 84)

a comma seperated list of allowed auth types, in order of preference

mixed $capabilities (line 99)
mixed $error (line 100)
mixed $error_raw (line 101)
mixed $fh (line 94)
mixed $fp (line 91)
mixed $host (line 77)
mixed $len (line 95)
mixed $line (line 90)
mixed $loggedin (line 98)
mixed $pass (line 80)
mixed $port (line 78)
mixed $responses (line 102)
mixed $retval (line 92)
mixed $script (line 96)
mixed $tmpfile (line 93)
mixed $user (line 79)
Methods
Constructor sieve (line 251)

Initialization of the SIEVE class.

It will return false if it fails, true if all is well. This also loads some arrays up with some handy information:

sieve sieve ($host $host, $port $port, $user $user, $pass $pass, [$auth $auth = ""], [$auth_types $auth_types = 'PLAIN'])
  • $host $host: string hostname to connect to. Usually the IMAP server where a SIEVE daemon, such as timsieved, is listening.
  • $port $port: string Numeric port to connect to. SIEVE daemons usually listen to port 2000.
  • $user $user: string is a super-user or proxy-user that has ACL rights to login on behalf of the $auth.
  • $pass $pass: string password to use for authentication
  • $auth $auth: string is the authorized user identity for which the SIEVE scripts will be managed.
  • $auth_types $auth_types:

    string a string containing all the allowed authentication types allowed in order of preference, seperated by spaces. (ex. "PLAIN DIGEST-MD5 CRAM-MD5" The method the library will try first is PLAIN.) The default for this value is PLAIN.

    Note: $user, if included, is the account name (and $pass will be the password) of an administrator account that can act on behalf of the user. If you are using Cyrus, you must make sure that the admin account has rights to admin the user. This is to allow admins to edit/view users scripts without having to know the user's password. Very handy.

authenticate (line 627)

Perform SASL authentication to SIEVE server.

Attempts to authenticate to SIEVE, using some SASL authentication method such as PLAIN or DIGEST-MD5.

void authenticate ()
get_response (line 110)

get response

void get_response ()
parse_for_quotes (line 279)

Tokenize a line of input by quote marks and return them as an array

  • return: Array of broken by quotes parts of original string
array parse_for_quotes ($string $string)
  • $string $string: string Input line to parse for quotes
sieve_alive (line 607)

Check availability of connection to the SIEVE server.

This function returns true or false based on whether the connection to the sieve server is still alive.

boolean sieve_alive ()
sieve_deletescript (line 567)

Attempt to delete the script requested.

If the script is currently active, the server will not have any active script after the deletion.

mixed sieve_deletescript ($scriptname $scriptname)
  • $scriptname $scriptname: string The name of the SIEVE script.
sieve_getscript (line 549)

Return the contents of the requested script.

If you want to display the script, you will need to change all CrLf to '.'.

  • return: SIEVE script data.
arr sieve_getscript ($scriptname $scriptname)
  • $scriptname $scriptname: string The name of the SIEVE script.
sieve_get_capability (line 758)

Return an array of available capabilities.

array sieve_get_capability ()
sieve_havespace (line 518)

Check if there is enough space for a script to be uploaded.

This function returns true or false based on whether the sieve server will allow your script to be sent and your quota has not been exceeded. This function does not currently work due to a believed bug in timsieved. It could be my code too.

It appears the timsieved does not honor the NUMBER type. see lex.c in timsieved src. don't expect this function to work yet. I might have messed something up here, too.

  • todo: Does not work; bug fix and test.
boolean sieve_havespace ($scriptname $scriptname, $scriptsize $scriptsize)
  • $scriptname $scriptname: string The name of the SIEVE script.
  • $scriptsize $scriptsize: integer The size of the SIEVE script.
sieve_listscripts (line 586)

List available scripts on the SIEVE server.

This function returns true or false. $sieve->response will be filled with the names of the scripts found. If a script is active, the $sieve->response["ACTIVE"] will contain the name of the active script.

boolean sieve_listscripts ()
sieve_login (line 361)

Attemp to log in to the sieve server.

It will return false if it fails, true if all is well. This also loads some arrays up with some handy information:

capabilities["implementation"] contains the sieve version information

capabilities["auth"] contains the supported authentication modes by the SIEVE server.

capabilities["modules"] contains the built in modules like "reject", "redirect", etc.

capabilities["starttls"] , if is set and equal to true, will show that the server supports the STARTTLS extension.

capabilities["unknown"] contains miscellaneous/extraneous header info sieve may have sent

boolean sieve_login ()
sieve_logout (line 468)

Log out of the sieve server.

  • return: Always returns true at this point.
boolean sieve_logout ()
sieve_sendscript (line 489)

Send the script contained in $script to the server.

It will return any error results it finds (in $sieve->error and $sieve->error_raw), and return true if it is successfully sent. The function does _not_ automatically make the script the active script.

  • return: Returns true if script has been successfully uploaded.
boolean sieve_sendscript ($scriptname $scriptname, $script $script)
  • $scriptname $scriptname: string The name of the SIEVE script.
  • $script $script: The script to be uploaded.
sieve_setactivescript (line 531)

Set the script active on the sieve server.

boolean sieve_setactivescript ($scriptname $scriptname)
  • $scriptname $scriptname: string The name of the SIEVE script.
status (line 313)

Parser for status responses.

This should probably be replaced by a smarter parser.

  • todo: remove this function and dependencies
void status ($string $string)
  • $string $string: string Input that contains status responses.

Documentation generated on Thu, 18 Dec 2003 15:18:54 +0200 by phpDocumentor 1.2.3