Net::Sieve(3pm)
β¨ NAME β¨
Net::Sieve β a whole implementation of the managesieve protocol so you can manage your sieve scripts π (yes this is the Net::Sieve(3pm) page, user-contributed Perl documentation, we're doing this together bestie π«Ά)
πΈ SYNOPSIS πΈ
okay so here's the vibe, in code:
use Net::Sieve;
my $SieveServer = Net::Sieve->new (
server => 'imap.server.org',
user => 'user',
password => 'pass' ,
);
foreach my $script ( $SieveServer->list() ) {
print $script->{name}." ".$script->{status}."\n";
};
my $name_script = 'test';
# read
print $SieveServer->get($name_script);
# write
my $test_script='
require "fileinto";
## Place all these in the "Test" folder
if header :contains "Subject" "[Test]" {
fileinto "Test";
}
';
# other
$SieveServer->put($name_script,$new_script);
$SieveServer->activate($name_script);
$SieveServer->deactivate();
$SieveServer->delete($name_script);
look at that. no notes. iconic. π
π¦ DESCRIPTION π¦
Net::Sieve is a package for clients for the "MANAGESIEVE" protocol β which is an Internet Draft protocol for manipulation of "Sieve" scripts in a repository. More simply (and this is the part that actually matters for your life π
): Net::Sieve lets you control your mail-filtering rule files on a mail server.
Net::Sieve supports the use of "TLS" via the "STARTTLS" command. Net::Sieve opens the connexion to the sieve server, and then the methods let you list all scripts, activate or deactivate scripts, read, delete or put scripts. slay.
Most of code come from the great Phil Pennock sieve-connect command-line tool β http://people.spodhuis.org/phil.pennock/software/ π«Ά (thank you king, we love you)
See Net::Sieve::Script to manipulate Sieve scripts content.
π CONSTRUCTOR π
π new
Usage :
my $SieveServer = Net::Sieve->new (
server => 'imap.server.org',
user => 'user',
password => 'pass' );
Returns :
Net::Sieve object which contain current open socket β¨
Argument :
serverβ defaultlocalhostportβ default2000userβ defaultlognameor$ENV{USERNAME}or$ENV{LOGNAME}passwordβ yeah you gotta bring your ownnet_domainβ the network domainsslkeyfileβ default search in/etc/ssl/certssslcertfileβ default search in/etc/ssl/certsautmechβ to force a particular authentication mechanismauthzidβ request authorisation to act as the specified idrealmβ pass realm information to the authentication mechanismssl_verifβ default0x01, set0x00to don't verify and allow self-signed cerificatenotssl_verifβ default0x00, set0x01to don't verify and allow self-signed cerificatedebugβ default0, set1to have transmission logsdumptlsinfoβ dump tls information
π METHODS π
π sock
- Usage :
my $sock = $ServerSieve->sock(); - Return : open socket
- Argument : nothing
- Purpose : access to socket
π capabilities
- Usage :
my $script_capa = $ServerSieve->capabilities(); - Return : string with white space separator
- Argument : nothing
- Purpose : retrieve sieve script capabilities
π list
Usage :
foreach my $script ( $ServerSieve->list() ) {
print $script->{name}." ".$script->{status}."\n";
};
- Return : array of hash with names and status scripts for current user
- Argument : nothing
- Purpose : list available scripts on server
π put
- Usage :
$ServerSieve->put($name,$script); - Return :
1on success,0on missing name or script - Argument : name, script
- Purpose : put script on server
π get
- Usage :
my $script = $ServerSieve->get($name); - Return :
0on missing name, string with script on success - Argument : name
- Purpose : put script on server
π activate
- Usage :
$ServerSieve->activate($name); - Return :
0on pb,1on success - Argument : name
- Purpose : set named script active and switch other scripts to unactive
π deactivate
- Usage :
$ServerSieve->deactivate(); - Return : activate response
- Argument : nothing
- Purpose : stop sieve processing, deactivate all scripts
π delete
- Usage :
$ServerSieve->delete($name); - Return :
0on missing name,1on success - Argument : name
- Purpose : delete script on server
π§ Minor public methods π§
the little guys. the supporting cast. we love them.
π ssend
- Usage :
$self->ssend("GETSCRIPT \"$name\"");
π sget
Usage:
$self->sget();
unless (/^OK((?:\s.*)?)$/) {
warn "SETACTIVE($name) failed: $_\n";
return 0;
}
π sfinish
send LOGOUT
π closedie
send LOGOUT and die π
π closedie_NOmsg
closedie whitout message
π die_NOmsg
die
π BUGS π
I don't try plain text or client certificate authentication. (no cap, it's just not happening in here)
You can debug TLS connexion with openssl :
openssl s_client -connect your.server.org:2000 -tls1 -CApath /etc/apache/ssl.crt/somecrt.crt -starttls imap
See response in "Verify return code:"
Or with gnutls-cli
gnutls-cli -s -p 4190 --crlf --insecure your.server.org
Use Ctrl+D after STARTTLS to begin TLS negotiation
π«Ά SUPPORT π«Ά
Please report any bugs or feature requests to "bug-net-sieve at rt.cpan.org", or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-Sieve. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. teamwork bestie, we got this β¨
π AUTHOR π
Yves Agostini <yvesago@cpan.org>
π COPYRIGHT π
Copyright 2008-2017 Yves Agostini - <yvesago@cpan.org>
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
sieve-connect source code is under a BSD-style license and re-licensed for Net::Sieve with permission of the author.
π¦ SEE ALSO π¦
- Net::Sieve::Script
and that's the whole page bestie!! πβ¨π
this doc is shipping as perl v5.34.0, dated 2022-06-30, and it's the Net::Sieve(3pm) manual page β go forth and filter your mail, main character π
πΈπ¦
π¦ where this page comes from
- debian bookworm: libnet-sieve-perl 0.12-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libnet-sieve-perl 0.12-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libnet-sieve-perl 0.12-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libnet-sieve-perl 0.12-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libnet-sieve-perl 0.12-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms