4 * Show additional message headers
6 * Proof-of-concept plugin which will fetch additional headers
7 * and display them in the message view.
9 * Enable the plugin in config/main.inc.php and add your desired headers:
10 * $rcmail_config['show_additional_headers'] = array('User-Agent');
13 * @author Thomas Bruederli
14 * @website http://roundcube.net
16 class show_additional_headers extends rcube_plugin
18 public $task = 'mail';
22 $rcmail = rcmail::get_instance();
23 if ($rcmail->action == 'show' || $rcmail->action == 'preview') {
24 $this->add_hook('imap_init', array($this, 'imap_init'));
25 $this->add_hook('message_headers_output', array($this, 'message_headers'));
26 } else if ($rcmail->action == '') {
27 // with enabled_caching we're fetching additional headers before show/preview
28 $this->add_hook('imap_init', array($this, 'imap_init'));
32 function imap_init($p)
34 $rcmail = rcmail::get_instance();
35 if ($add_headers = (array)$rcmail->config->get('show_additional_headers', array()))
36 $p['fetch_headers'] = trim($p['fetch_headers'].' ' . strtoupper(join(' ', $add_headers)));
41 function message_headers($p)
43 $rcmail = rcmail::get_instance();
44 foreach ((array)$rcmail->config->get('show_additional_headers', array()) as $header) {
45 $key = strtolower($header);
46 if ($value = $p['headers']->others[$key])
47 $p['output'][$key] = array('title' => $header, 'value' => Q($value));