summaryrefslogtreecommitdiff
path: root/plugins/additional_message_headers
diff options
context:
space:
mode:
authorHugues Hiegel <root@paranoid>2015-04-21 12:49:44 +0200
committerHugues Hiegel <root@paranoid>2015-04-21 12:49:44 +0200
commit733f8e8d0ce6217d906d06dc4fb08e36d48ed794 (patch)
treecff28366ff63ea6596f8026e1698090bd0b9405c /plugins/additional_message_headers
parentef2e7b3f9d264ec146d4dae257b1e295ab3b462a (diff)
parenta4ba3df54834ee90fb2c9930669f1229dc80261a (diff)
Merge remote-tracking branch 'origin/master'HEADmaster
Conflicts: composer.json-dist config/defaults.inc.php plugins plugins/acl/acl.js plugins/acl/acl.php plugins/acl/skins/classic/templates/table.html plugins/acl/skins/larry/templates/table.html plugins/enigma/README plugins/enigma/config.inc.php.dist plugins/enigma/enigma.js plugins/enigma/enigma.php plugins/enigma/lib/enigma_driver.php plugins/enigma/lib/enigma_driver_gnupg.php plugins/enigma/lib/enigma_driver_phpssl.php plugins/enigma/lib/enigma_engine.php plugins/enigma/lib/enigma_error.php plugins/enigma/lib/enigma_key.php plugins/enigma/lib/enigma_signature.php plugins/enigma/lib/enigma_subkey.php plugins/enigma/lib/enigma_ui.php plugins/enigma/lib/enigma_userid.php plugins/enigma/localization/en_US.inc plugins/enigma/localization/ja_JP.inc plugins/enigma/localization/ru_RU.inc plugins/enigma/skins/classic/enigma.css plugins/enigma/skins/classic/templates/keys.html plugins/help/config.inc.php.dist plugins/help/help.php plugins/help/localization/en_US.inc plugins/jqueryui/jqueryui.php plugins/managesieve/Changelog plugins/managesieve/composer.json plugins/managesieve/config.inc.php.dist plugins/managesieve/lib/Roundcube/rcube_sieve.php plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php plugins/managesieve/lib/Roundcube/rcube_sieve_vacation.php plugins/managesieve/localization/en_US.inc plugins/managesieve/managesieve.js plugins/managesieve/skins/classic/managesieve.css plugins/managesieve/skins/larry/managesieve.css plugins/password/README plugins/password/config.inc.php.dist plugins/password/drivers/ldap.php plugins/password/drivers/poppassd.php plugins/password/drivers/vpopmaild.php plugins/vcard_attachments/vcardattach.js plugins/zipdownload/zipdownload.php
Diffstat (limited to 'plugins/additional_message_headers')
-rw-r--r--plugins/additional_message_headers/additional_message_headers.php46
-rw-r--r--plugins/additional_message_headers/composer.json24
-rw-r--r--plugins/additional_message_headers/config.inc.php.dist14
-rw-r--r--plugins/additional_message_headers/tests/AdditionalMessageHeaders.php23
4 files changed, 107 insertions, 0 deletions
diff --git a/plugins/additional_message_headers/additional_message_headers.php b/plugins/additional_message_headers/additional_message_headers.php
new file mode 100644
index 000000000..0d16e605e
--- /dev/null
+++ b/plugins/additional_message_headers/additional_message_headers.php
@@ -0,0 +1,46 @@
+<?php
+
+/**
+ * Additional Message Headers
+ *
+ * Very simple plugin which will add additional headers
+ * to or remove them from outgoing messages.
+ *
+ * Enable the plugin in config.inc.php and add your desired headers:
+ * $config['additional_message_headers'] = array('User-Agent' => 'My-Very-Own-Webmail');
+ *
+ * @version @package_version@
+ * @author Ziba Scott
+ * @website http://roundcube.net
+ */
+class additional_message_headers extends rcube_plugin
+{
+ function init()
+ {
+ $this->add_hook('message_before_send', array($this, 'message_headers'));
+ }
+
+ function message_headers($args)
+ {
+ $this->load_config();
+
+ $headers = $args['message']->headers();
+ $rcube = rcube::get_instance();
+
+ // additional email headers
+ $additional_headers = $rcube->config->get('additional_message_headers', array());
+ foreach ((array)$additional_headers as $header => $value) {
+ if (null === $value) {
+ unset($headers[$header]);
+ }
+ else {
+ $headers[$header] = $value;
+ }
+ }
+
+ $args['message']->_headers = array();
+ $args['message']->headers($headers);
+
+ return $args;
+ }
+}
diff --git a/plugins/additional_message_headers/composer.json b/plugins/additional_message_headers/composer.json
new file mode 100644
index 000000000..bf3f6c4d7
--- /dev/null
+++ b/plugins/additional_message_headers/composer.json
@@ -0,0 +1,24 @@
+{
+ "name": "roundcube/additional_message_headers",
+ "type": "roundcube-plugin",
+ "description": "Very simple plugin which will add additional headers to or remove them from outgoing messages.",
+ "license": "GPLv2",
+ "version": "1.2.0",
+ "authors": [
+ {
+ "name": "Ziba Scott",
+ "email": "email@example.org",
+ "role": "Lead"
+ }
+ ],
+ "repositories": [
+ {
+ "type": "composer",
+ "url": "http://plugins.roundcube.net"
+ }
+ ],
+ "require": {
+ "php": ">=5.3.0",
+ "roundcube/plugin-installer": ">=0.1.3"
+ }
+}
diff --git a/plugins/additional_message_headers/config.inc.php.dist b/plugins/additional_message_headers/config.inc.php.dist
new file mode 100644
index 000000000..904681349
--- /dev/null
+++ b/plugins/additional_message_headers/config.inc.php.dist
@@ -0,0 +1,14 @@
+<?php
+
+// $config['additional_message_headers']['X-Remote-Browser'] = $_SERVER['HTTP_USER_AGENT'];
+// $config['additional_message_headers']['X-Originating-IP'] = '[' . $_SERVER['REMOTE_ADDR'] .']';
+// $config['additional_message_headers']['X-RoundCube-Server'] = $_SERVER['SERVER_ADDR'];
+
+// if( isset( $_SERVER['MACHINE_NAME'] )) {
+// $config['additional_message_headers']['X-RoundCube-Server'] .= ' (' . $_SERVER['MACHINE_NAME'] . ')';
+// }
+
+// To remove (e.g. X-Sender) message header use null value
+// $config['additional_message_headers']['X-Sender'] = null;
+
+?>
diff --git a/plugins/additional_message_headers/tests/AdditionalMessageHeaders.php b/plugins/additional_message_headers/tests/AdditionalMessageHeaders.php
new file mode 100644
index 000000000..55e8c441e
--- /dev/null
+++ b/plugins/additional_message_headers/tests/AdditionalMessageHeaders.php
@@ -0,0 +1,23 @@
+<?php
+
+class AdditionalMessageHeaders_Plugin extends PHPUnit_Framework_TestCase
+{
+
+ function setUp()
+ {
+ include_once __DIR__ . '/../additional_message_headers.php';
+ }
+
+ /**
+ * Plugin object construction test
+ */
+ function test_constructor()
+ {
+ $rcube = rcube::get_instance();
+ $plugin = new additional_message_headers($rcube->api);
+
+ $this->assertInstanceOf('additional_message_headers', $plugin);
+ $this->assertInstanceOf('rcube_plugin', $plugin);
+ }
+}
+