Setting actual sender for e-mails in shared Sent Items folder in Roundcube Webmail

Recently, I came across the requirement to set up shared IMAP folders in Roundcube Webmail for a Dovecot IMAP server setting.

Everything went smoothly using the respective Dovecot setup in conjunction with the Roundcube ACL plugin for IMAP Folders Access Control Lists Management (RFC4314, RFC2086).

Everything? Well not quite everything.

The problem was that for e-mails in shared Sent Items folders not the actual sender was shown but the owner of the shared folder. So, for instance if had subscribed to the Sent Items of then was shown as sender instead of the actual sender (e.g.

Which makes it quite cumbersome to retrieve the actual sender, e.g. by having a look at the e-mail headers…

Let’s write a Roundcube Plugin

Since there is no evident setting in Roundcube for achieving this (expected) behavior I had quick look at the possibilities from a programmatic point of view.

Roundcube has a very nice plugin architecture for accessing hooks to e.g. manipulate e-mails when the e-mail list of being loaded before it is actually sent out.

So, the idea was to simply alter all e-mail senders for shared Sent Items folders. In my setup, shared folders are conveniently configured with the prefix “shared/” via the Dovecot configuration, leading the shared IMAP folders such as “shared/ Items“.

Without further ado, find the Roundcube plugin code below that matches those requirements quite nicely with only a couple of lines of code.


 * Displays actual sender for e-mails in shared Sent folder.
 * @author Matthias Kerstner
class show_actual_sender_for_shared_sent_folder extends rcube_plugin
  public $task = 'mail';
  function init()  {
    $this->add_hook('messages_list', array($this, 'do_show_actual_sender_for_shared_sent_folder'));

  function do_show_actual_sender_for_shared_sent_folder($args) {

    // $this->load_config(); -> Hint: we could load the regexp here to make it configurable
    foreach($args['messages'] as $msg) {		
      if(preg_match('#^shared\/[^\/]+\/Sent( Items)?$#', $msg->folder)) {
        $msg->from = $msg->to;
    return $args;

Potential improvements

As you can see in the code comment the regexp for matching the shared Sent Items (or any other folder structure you prefer) could be easily loaded via the plugin configuration. But that’s something up to you 🙂

If there’s time I’ll publish this wonderful plugin on the Roundcube Plugin repository. In the meantime I’ll link the plugin download file here.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.