Home Contact Sitemap Todo Money

Alan K Holden

Accomplished Internaut

Getting MarkAsJunk2 to Work on Roundcube

Roundcube & MarkAsJunk2

Some employers and clients don't open a lot of outside ports for security reasons, which I can understand. After all, who wants a handful - out of all the computers they manage - "going rogue" and opening up their own little email shop on the side? So it was time to loose my ancient habit of using Thunderbird on site to poll my own server for mail - and install a browser-based email service there instead.

Enter Roundcube, an open source IMAP email (ie Webmail) client that runs on PHP. It looks pretty slick and runs fine (as long as you install the correct version for your system). The core version can be pretty sparse, but a group of developers have authored a bunch of plugins - to round out the feature set nicely. (There's also SquirrelMail, but I had problems getting their plugins to actually plug in.)

Virtually every Roundcube plugin installed easily. I've only had problems customizing one of them - MarkAsJunk2 - a plugin that not only let's you click off your spam, but optionally tells third-parties that you've done so.

You see, I have an account with KnujOn, a group which collects and analyzes junk email in order to test the Internet's policy infrastructure and target illicit transaction sites at the point of purchase. So every time I click on the MarkAsJunk2 button, I wanted my Roundcube server to send a copy of the message to KnujOn for me.

MarkAsJunk2 provides a "driver" to do this (called "email_learn"), but the copy I got from the repository was broken. The RoundCube screen would complain of a server error, and the local error log file would contain messages like this:

PHP Fatal error:  Call to undefined method stdClass::get_raw_body() in .../roundcubemail/plugins/markasjunk2/drivers/email_learn.php
PHP Fatal error:  Call to undefined method stdClass::set_flag() in .../roundcubemail/plugins/markasjunk2/markasjunk2.php


After finding this post regarding a similar driver, I figured out how to get it working. So I don't forget next time, here's how I did it:

I'm not going to describe how to install Roundcube or the plugin, that's pretty well documented. Just remember to set up the plugin's own config file correctly, naming the 'email_learn' driver and the target address (to get a copy of the spam) on the proper lines. Now, on to my bug:

The core issue with my version of MarkAsJunk2 was in sections of code which point to a method called "storage". Apparently that doesn't exist in my Roundcube, so I found those references and replaced them with "imap"... which does exist.

I changed /roundcubemail/plugins/markasjunk2/drivers/email_learn.php

around line 70 or so:

//OLD $rcmail->storage->set_charset($MESSAGE->headers->charset);


and again a few lines down:

//OLD $raw_message = $rcmail->storage->get_raw_body($uid);
$raw_message = $rcmail->imap->get_raw_body($uid);

Then I changed /roundcubemail/plugins/markasjunk2/markasjunk2.php

around line 98 or so:

//OLD  $storage = $rcmail->storage;
// NEW
$storage = $rcmail->imap;

At this point I restarted Apache (just to reload PHP's init for the heck of it), and everything seemed to work.

I haven't had any problems since.



Post a Comment

Required Field

My Details
Subscription Settings

Hear about status updates or new posts.