commit | author | age
|
48e9c1
|
1 |
<?php |
T |
2 |
|
|
3 |
/** |
|
4 |
* Additional Message Headers |
|
5 |
* |
|
6 |
* Very simple plugin which will add additional headers |
|
7 |
* to or remove them from outgoing messages. |
|
8 |
* |
461a30
|
9 |
* Enable the plugin in config.inc.php and add your desired headers: |
465fc3
|
10 |
* $config['additional_message_headers'] = array('User-Agent' => 'My-Very-Own-Webmail'); |
48e9c1
|
11 |
* |
T |
12 |
* @version @package_version@ |
|
13 |
* @author Ziba Scott |
|
14 |
* @website http://roundcube.net |
|
15 |
*/ |
|
16 |
class additional_message_headers extends rcube_plugin |
|
17 |
{ |
|
18 |
function init() |
|
19 |
{ |
6efadf
|
20 |
$this->add_hook('message_before_send', array($this, 'message_headers')); |
48e9c1
|
21 |
} |
T |
22 |
|
|
23 |
function message_headers($args) |
|
24 |
{ |
6efadf
|
25 |
$this->load_config(); |
AM |
26 |
|
b2d4cf
|
27 |
$rcube = rcube::get_instance(); |
48e9c1
|
28 |
|
T |
29 |
// additional email headers |
6efadf
|
30 |
$additional_headers = $rcube->config->get('additional_message_headers', array()); |
48e9c1
|
31 |
|
b2d4cf
|
32 |
if (!empty($additional_headers)) { |
efe06f
|
33 |
// Mail_mime >= 1.9.0 |
AM |
34 |
if (method_exists($message, 'isMultipart')) { |
|
35 |
$args['message']->headers($additional_headers, true); |
|
36 |
} |
|
37 |
else { |
|
38 |
$headers = $args['message']->headers(); |
|
39 |
|
|
40 |
foreach ((array) $additional_headers as $header => $value) { |
|
41 |
if ($value === null) { |
|
42 |
unset($headers[$header]); |
|
43 |
} |
|
44 |
else { |
|
45 |
$headers[$header] = $value; |
|
46 |
} |
|
47 |
} |
|
48 |
|
|
49 |
$args['message']->_headers = array(); |
|
50 |
$args['message']->headers($headers); |
|
51 |
} |
b2d4cf
|
52 |
} |
6efadf
|
53 |
|
48e9c1
|
54 |
return $args; |
T |
55 |
} |
|
56 |
} |