Net::Sieve(3pm)

πŸ“¦
version 0.12 Β· 2 versions
  • 0.12 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.12 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

✨ 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 β€” default localhost
  • port β€” default 2000
  • user β€” default logname or $ENV{USERNAME} or $ENV{LOGNAME}
  • password β€” yeah you gotta bring your own
  • net_domain β€” the network domain
  • sslkeyfile β€” default search in /etc/ssl/certs
  • sslcertfile β€” default search in /etc/ssl/certs
  • autmech β€” to force a particular authentication mechanism
  • authzid β€” request authorisation to act as the specified id
  • realm β€” pass realm information to the authentication mechanism
  • ssl_verif β€” default 0x01, set 0x00 to don't verify and allow self-signed cerificate
  • notssl_verif β€” default 0x00, set 0x01 to don't verify and allow self-signed cerificate
  • debug β€” default 0, set 1 to have transmission logs
  • dumptlsinfo β€” 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 : 1 on success, 0 on missing name or script
  • Argument : name, script
  • Purpose : put script on server

πŸ’Œ get

  • Usage : my $script = $ServerSieve->get($name);
  • Return : 0 on missing name, string with script on success
  • Argument : name
  • Purpose : put script on server

πŸ’Œ activate

  • Usage : $ServerSieve->activate($name);
  • Return : 0 on pb, 1 on 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 : 0 on missing name, 1 on 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 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