henrique-borba / 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.
Installs: 53 672
Dependents: 1
Suggesters: 0
Security: 0
Stars: 16
Watchers: 4
Forks: 3
Open Issues: 1
Requires
- php: >=5.4
README
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
addheader [":last"]
<field-name: string>
<value: string>
deleteheader [":index" <fieldno: number> [":last"]]
[COMPARATOR] [MATCH-TYPE]
<field-name: string>
[<value-patterns: string-list>]
notify [":from" string]
[":importance" <"1" / "2" / "3">]
[":options" string-list]
[":message" string]
[:fcc "INBOX.Sent"]
<method: string>
vacation [[":days" number] | [":seconds"]]
[":subject" string]
[":from" string]
[":addresses" string-list]
[":mime"]
[":handle" string]
<reason: string>
setflag [<variablename: string>]
<list-of-flags: string-list>
addflag [<variablename: string>]
<list-of-flags: string-list>
removeflag [<variablename: string>]
<list-of-flags: string-list>
replace [":mime"]
[":subject" string]
[":from" string]
<replacement: string>
enclose <:subject string>
<:headers string-list>
string
extracttext [MODIFIER]
[":first" number]
<varname: string>
convert <quoted-from-media-type: string>
<quoted-to-media-type: string>
<transcoding-params: string-list>
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>
redirect [":copy"] [:notify "value"] [:ret "FULL"|"HDRS"] [":copy"] <address: string>
keep [":flags" <list-of-flags: string-list>]
discard
reject
ereject