Coder Social home page Coder Social logo

cypht-org / php-sieve-manager Goto Github PK

View Code? Open in Web Editor NEW
16.0 4.0 3.0 85 KB

A modern (started in 2022) PHP library for the ManageSieve protocol (RFC5804) to create/edit Sieve scripts (RFC5228)

License: MIT License

PHP 100.00%
php sieve email imap managesieve rfc5228 sieve-library sieve-parsing filter rfc5804

php-sieve-manager's Introduction

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

php-sieve-manager's People

Contributors

henrique-borba avatar josaphatim avatar kroky avatar marclaporte avatar shadow243 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

php-sieve-manager's Issues

php-sieve-manager seems to prevent software to run on shared hosting

Dear @henrique-borba,
(cc. @marclaporte )

I am member of the community of the Tiki app, which uses a Cypht integration for our webmail feature.
Cypht uses php-sieve-manager for server side filtering.
And php-sieve-manager requires the php extension ext-sockets.

Because ext-sockets is not available with my shared hosting provider (all-inkl.com), I discussed with their support what would be the reason. They told me that sockets would have to be installed and configured globally per server and customers sharing a server would be able to unintendedly interfere with each others configuration or data ... it would be a security issue to provide sockets for shared servers. So it would be likely rare that shared hosting provider would provide sockets and if yes it would not be recommended to use them.

This is a problem for us - at least for me ;-) .

What is the reason, that php-sieve-manager requires ext-sockets and would it be possible to make server side filtering working (similar fast and stable) without ext-sockets?

I'd appreciate any feedback and the opportunity to discuss the issue with you.

Following the error message of the (shared hosting) servers command line when trying to install the composer dependencies:

`
Local PHP version 74 >= to required PHP version 74 - good
You are already using the latest available Composer version 2.4.1 (2.x channel).
....

Problem 1
- henrique-borba/php-sieve-manager is locked to version dev-master and an update of this package was not requested.
- henrique-borba/php-sieve-manager dev-master requires ext-sockets * -> it is missing from your system. Install or enable PHP's sockets extension.

Problem 2
- henrique-borba/php-sieve-manager dev-master requires ext-sockets * -> it is missing from your system. Install or enable PHP's sockets extension.
- jason-munro/cypht dev-master requires henrique-borba/php-sieve-manager dev-master -> satisfiable by henrique-borba/php-sieve-manager[dev-master].
- jason-munro/cypht is locked to version dev-master and an update of this package was not requested.
`

Best regards,
Torsten

Maximum execution time of 30+2 seconds exceeded

Fatal error: Maximum execution time of 30+2 seconds exceeded (terminated) in vendor_bundled/vendor/henrique-borba/php-sieve-manager/src/ManageSieve/Client.php on line 93

When I try to see the details of an email I have this error after several attempts. It may be due to my internet connection.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.