#1486548 closed Feature Requests (fixed)
Hook to change Sent folder on compose message
| Reported by: | emi | Owned by: | |
|---|---|---|---|
| Priority: | 5 | Milestone: | 0.4-beta |
| Component: | Plugin API | Version: | 0.3.1 |
| Severity: | normal | Keywords: | hook, compose, sent folder |
| Cc: | m.duelli@… |
Description
Hello,
I'm looking for a way to make Roundcube save sent mails automatically into a time based folder name. It needs to concatenate the Sent special folder name with a time based string, separating each with the folders separator (normally . ). A good place to do that is in compose window: function rcmail_store_target_selection, file program/steps/mail/compose.inc, line 1016 of current roundcube version ( http://trac.roundcube.net/browser/trunk/roundcubemail/program/steps/mail/compose.inc ).
It may be a good idea to put there a hook to let plugins change the normal behavior. The code should be something like that:
function rcmail_store_target_selection($attrib)
{
$attrib['name'] = '_store_target';
$select = rcmail_mailbox_select(array_merge($attrib, array('noselection' => '- '.rcube_label('dontsave').' -')));
/// Change
$folder =
rcmail::get_instance()->plugins->exec_hook(
'message_compose_save_folder',
rcmail::get_instance()->config->get('sent_mbox'));
return $select->show($folder, $attrib);
}
Only with this change on trunk there will be a possibility to easily modify normal behavior, instead of hacking main.inc.php, what is nasty enough to try to avoid it:
$rcmail_config['sent_mbox'] = 'Sent.' . date('Y.m');
Plugins will be able to choose (and create if necessary) the final folder where the message will be saved, taking care of user and server preferences. For example, you'll be able to make a plugin that lets you choose where to save sent messages depending on the person it's addressed to and/or organizing the folder into subfolders to organize mails with a time based logic (separating by year and month, for example).
Change History (6)
comment:1 Changed 3 years ago by duelli
- Cc m.duelli@… added
comment:2 follow-up: ↓ 3 Changed 3 years ago by emi
Hi there,
It's just this kind of situations (in a reply) where a plugin could, with this hook, operate on a per destination address basis.
Another possibility is to take the save folder from params if it's defined, so plugins will be able to modify it with existing message_compose hook:
function rcmail_store_target_selection($attrib)
{
$attrib['name'] = '_store_target';
$select = rcmail_mailbox_select(array_merge($attrib, array('noselection' => '- '.rcube_label('dontsave').' -')));
/// Change
$folder =
$_SESSION['compose']['param']['sent_mbox'] ?
$_SESSION['compose']['param']['sent_mbox'] :
rcmail::get_instance()->config->get('sent_mbox');
return $select->show(rcmail::get_instance()->config->get('sent_mbox'), $attrib);
}
comment:3 in reply to: ↑ 2 Changed 3 years ago by emi
Replying to emi:
Some code correction. Sorry:
function rcmail_store_target_selection($attrib)
{
$attrib['name'] = '_store_target';
$select = rcmail_mailbox_select(array_merge($attrib, array('noselection' => '- '.rcube_label('dontsave').' -')));
/// Change
$folder =
$_SESSION['compose']['param']['sent_mbox'] ?
$_SESSION['compose']['param']['sent_mbox'] :
rcmail::get_instance()->config->get('sent_mbox');
return $select->show($folder, $attrib);
}
comment:4 Changed 3 years ago by thomasb
- Version changed from devel-threads to 0.3.1
I vote for emi's solution together with the compose_message hook.
comment:5 Changed 3 years ago by thomasb
- Resolution set to fixed
- Status changed from new to closed
Added in [814905ca]. You can now use the message_compose hook to modify the sent_mbox parameter.
comment:6 Changed 3 years ago by emi
Thanks a lot!
There will be plenty of new plugins soon!!
See you!

Guess this would also help to implement this feature request #1485945