Skip to content

Latest commit

 

History

History
187 lines (132 loc) · 4.92 KB

README.md

File metadata and controls

187 lines (132 loc) · 4.92 KB

php-sieve-manager

A modern (started in 2022) PHP library for the ManageSieve protocol (RFC5804) to create/edit Sieve scripts (RFC5228). Used by Cypht Webmail and available to all PHP projects via https://packagist.org/packages/henrique-borba/php-sieve-manager

Tiki Wiki CMS Groupware bundles Cypht webmail and extends filters beyond what is possible via the Sieve protocol.

Compare php-sieve-manager to other options

How to use

Connect to ManageSieve

require_once "vendor/autoload.php";

$client = new \PhpSieveManager\ManageSieve\Client("localhost", 4190);
$client->connect("test@localhost", "mypass", false, "", "PLAIN");


$client->listScripts();

Generate Sieve script

$filter = \PhpSieveManager\Filters\FilterFactory::create('MaxFileSize');


$criteria = \PhpSieveManager\Filters\FilterCriteria::if('body')->contains('"test"');

// Messages bigger than 2MB will be rejected with an error message
$size_condition = new \PhpSieveManager\Filters\Condition(
    "Messages bigger than 2MB will be rejected with an error message", $criteria
);

$size_condition->addCriteria($criteria);
$size_condition->addAction(
     new \PhpSieveManager\Filters\Actions\DiscardFilterAction()
);


// Add the condition to the Filter
$filter->setCondition($size_condition);
$filter->toScript();

Actions

[RFC5293]

addheader [":last"]
    <field-name: string>
    <value: string>

[RFC5293]

deleteheader [":index" <fieldno: number> [":last"]]
    [COMPARATOR] [MATCH-TYPE]
    <field-name: string>
    [<value-patterns: string-list>]

[RFC8580] [RFC5435]

notify [":from" string]
    [":importance" <"1" / "2" / "3">]
    [":options" string-list]
    [":message" string]
    [:fcc "INBOX.Sent"]
    <method: string>

[RFC5230] [RFC6131] [RFC8580]

vacation [[":days" number] | [":seconds"]]
    [":subject" string]
    [":from" string]
    [":addresses" string-list]
    [":mime"]
    [":handle" string]
    <reason: string>

[RFC5232]

setflag [<variablename: string>]
    <list-of-flags: string-list>

[RFC5232]

addflag [<variablename: string>]
    <list-of-flags: string-list>

[RFC5232]

removeflag [<variablename: string>]
    <list-of-flags: string-list>

[RFC5703]

replace [":mime"]
    [":subject" string]
    [":from" string]
    <replacement: string>

[RFC5703]

enclose <:subject string>
    <:headers string-list>
    string

[RFC5229]

extracttext [MODIFIER]
    [":first" number]
    <varname: string>

[RFC6558]

convert  <quoted-from-media-type: string>
    <quoted-to-media-type: string>
    <transcoding-params: string-list>

[RFC5229]

set [MODIFIER] <name: string>
    <value: string>

Modifiers:  ":lower" / ":upper" / ":lowerfirst" / ":upperfirst" /
           ":quotewildcard" / ":length"

[RFC5232] [RFC3894] [RFC5228] [RFC5490] [RFC9042] [RFC8579]

fileinto [:mailboxid <mailboxid: string>] [:specialuse <special-use-attr: string>] [:create] [":copy"] [":flags" <list-of-flags: string-list>] <mailbox: string>

[RFC5228] [RFC3894] [RFC6009]

redirect [":copy"] [:notify "value"] [:ret "FULL"|"HDRS"] [":copy"] <address: string>

[RFC5228] [RFC5232]

keep [":flags" <list-of-flags: string-list>]

[RFC5228]

discard

[RFC5429]

reject

[RFC5429]

ereject