Roundcube Community Forum

 

[SOLVED] Show real sender for shared "Sent Items" folder

Started by mkrc21, April 11, 2021, 06:43:07 AM

Previous topic - Next topic

mkrc21

Hello,

I've configured RC to support shared folders (acl plugin together with dovecot) - which works perfectly.

But I'm searching for a way to display the real sender in the "fromto" for emails shown in a shared "Sent Items" folder, instead
of the user's email sharing this folder.

To clarify:

1) user@mail.com is sharing his Sent Items folder

2) other-user@mail.com subscribed to user@mail.com's shared Sent Items

3) Instead of the real sender other-user@mail.com always sees user@mail.com as sender for emails in the Sent Items folder


Can somebody please direct me in a way to solve this issue?

I'm glad to write a plugin - but I currently don't have a good starting point.

Ideally, the sender should only be adapted for subscriptions to shared "Sent Items" folders.

Thanks a lot.

mkrc21

#1
Already found a solution after checking the plugin hooks.

I am using the messages_list hook for a custom plugin which works (surprise, suprise) as it should and I'm able
to change the sender accordingly.

Great, if something documented just works :)

In case you are interested here's the code:


<?php

/**
 * 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();

foreach($args['messages'] as $msg) {   
  if(preg_match('#^shared\/[^\/]+\/Sent( Items)?$#'$msg->folder)) {
$msg->from $msg->to;
  }
}

        return 
$args;
    }
}