Skip to content

Psych0meter/roundcube-block_list

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

block_list — Roundcube plugin

Adds a "Block list" panel to Settings and a "Block sender" button to the mail view. Both write to the same Sieve rule that silently discards messages from listed senders before other filters are evaluated.


What it does

Settings panel

A dedicated panel appears in the Settings sidebar alongside Filters. It shows the block list in alphabetical order with a live search filter. Addresses can be added by typing and pressing Enter (or clicking Add) and removed with the Remove button next to each entry. Changes are saved to the Sieve server immediately after each add or remove — there is no separate Save button.

Mail view button

A "Block sender" item appears in the popup menu that opens when you click a From, To, or Cc address in a message. Clicking it adds that address to the block list in one step and redirects to the Settings panel so you can review the result.

Sieve rule

The plugin manages exactly one rule named "Block list" in the user's active Sieve script:

# rule:[Block list]
if anyof (address :all :is "from" ["[email protected]","[email protected]"])
{
    discard;
    stop;
}

Because the rule uses the standard # rule:[name] marker, it is also visible and editable in the regular Filters UI.

When the address list is empty the rule is removed from the script entirely. Sieve rejects an empty address list as invalid syntax, so disabling rather than emptying the rule is not an option.

Logging

Every addition and removal is recorded in logs/blocklist (a standard Roundcube log file, location controlled by $config['log_dir']):

[2025-07-01 05:13:44 +0000]: <f22ab226> [BLOCKLIST] [[email protected]] [192.0.2.1] added: [email protected]
[2025-07-01 05:14:01 +0000]: <f22ab226> [BLOCKLIST] [[email protected]] [192.0.2.1] removed: [email protected]

The timestamp is added by Roundcube. The fields are user login, client IP, action, and address.


Requirements

  • Roundcube 1.5 or later (elastic skin, Sieve library under lib/Roundcube/)
  • The managesieve plugin installed and listed in $config['plugins']
  • A Sieve-capable mail server (Cyrus, Dovecot, etc.) reachable from Roundcube

Installation

  1. Copy the plugin directory into Roundcube's plugins/ folder:

    plugins/
      managesieve/          <- must already be present
      block_list/
        block_list.php
        blocklist.js
        localization/
          en_US.inc
        skins/
          elastic/
            blocklist.css
            templates/
              blocklist.html
    
  2. Add block_list to the plugins list in config/config.inc.php. It must appear after managesieve:

    $config['plugins'] = ['managesieve', 'block_list'];
    
  3. Clear Roundcube's template cache (delete the contents of temp/ or use Settings > About > Clear cache) and reload the page.

A "Block list" entry should now appear in the Settings sidebar.


Configuration

The plugin inherits all connection settings from managesieve (managesieve_host, managesieve_port, managesieve_usetls, etc.). No additional configuration keys are required.

If you store Sieve scripts under a non-default name, ensure $config['managesieve_script_name'] is set correctly in your managesieve configuration. The plugin reads this key to load the correct script.


How the Sieve connection works

The plugin does not re-implement Sieve connectivity. It loads rcube_sieve_engine from the managesieve plugin's lib/Roundcube/ directory and calls its connect() method, which handles host name resolution, port defaulting (4190), TLS negotiation, the managesieve_connect plugin hook, and SASL authentication — identical to the regular Filters UI. The resulting rcube_sieve instance is obtained via PHP Reflection because the engine stores it in a protected property.


Translating

Copy localization/en_US.inc to localization/{locale}.inc and translate the right-hand string values. The array keys must not be changed. Locale codes follow the same convention as the rest of Roundcube (fr_FR, de_DE, etc.).


Notes

  • Address matching uses :all :is "from", which tests the full From header value (including display name in some Sieve implementations). Matching is case-insensitive at the Sieve level and on the server before saving.
  • Adding the same address twice (different case) is silently deduplicated.
  • The "Block list" rule is evaluated in whatever position it occupies in the script. If you reorder rules in the Filters UI, keep "Block list" near the top to ensure blocked mail is discarded before forwarding or filing rules act on it.

About

Roundcube plugin — manage a Sieve block list to silently discard mail from specific senders

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors