[imp] Spam / Innocent buttons

Jens Wahnes wahnes at uni-koeln.de
Fri Mar 26 09:53:49 UTC 2021


Simon Wilson wrote:
> Is there a way to have the 'Innocent' button shown on Inbox (dynamic 
> view) for one user only?

Yes, you can do this by defining several mail server backends in Imp's 
backends.local.php.  Besides your regular backend that everybody is 
using, make a copy of that backend and enable the "spam" array key and 
the subordinate array keys on this second backend only.  Of course, the 
second backend should refer to the exact same IMAP server as the first 
one (regarding "hostspec" etc.).  The only difference between the two 
backends should really be the "spam" setting.  Then, regular users, who 
connect to the first backend, will not see the buttons you are referring 
to, because their mail server does not have spam filtering capabilities 
enabled.

The only remaining task is to assign your username (or a set of users 
including you) to the new backend server that does have the spam setting 
enabled.  This can be done using a hook.  I'd recommend to put a hook 
into Imp's config directory using a file named "hooks.local.php", 
because "hooks.php" will be overwritten upon updates of Horde groupware. 
  So I'd suggest to make a copy of hooks.php and call it 
hooks.local.php, plus rename the original hooks.php e.g. to 
hooks.original.php (you'll need to repeat this rename or delete step on 
every update).  Inside the hooks.local.php file, you'll need to fill in 
the preauthenticate function.  It could look like this:

public function preauthenticate($userId, $credentials) {
   $spamreportserver="spamreport"; # Key from backends.local.php
   $spamtester=array("yourusernamehere","afellowtester");

   if ( ($userId) && (($credentials['authMethod']=='authenticate') || 
($credentials['authMethod']=='transparent')) ) {

     if (in_array($userId, $spamtester)) {
       Horde::log("$userId is a spamtester, so sending to spamreport 
server", "INFO");
       $credentials['server'] = $spamreportserver;
       $credentials['transparent'] = true;
       return array(
         'credentials' => $credentials,
         'userId' => $userId
       );
     } # if Spamtester
   }
}

For more information on what the hook file should look like, take a look 
at the examples given in hooks.php.dist


Jens


More information about the imp mailing list