diff --git a/src/testsuite/cmd-test-message.c b/src/testsuite/cmd-test-message.c
index c906f9ec59eba3606c160d0afc8790c2da9d8924..a1a4e985521f094237e357bc5b014a4e0df34640 100644
--- a/src/testsuite/cmd-test-message.c
+++ b/src/testsuite/cmd-test-message.c
@@ -1,8 +1,12 @@
 /* Copyright (c) 2002-2011 Pigeonhole authors, see the included COPYING file
  */
 
+#include "lib.h"
+#include "istream.h"
+
 #include "sieve-common.h"
 #include "sieve-commands.h"
+#include "sieve-message.h"
 #include "sieve-validator.h"
 #include "sieve-generator.h"
 #include "sieve-interpreter.h"
@@ -15,7 +19,10 @@
 #include "testsuite-mailstore.h"
 
 /*
- * Test_message command
+ * Commands
+ */ 
+
+/* Test_message command
  *
  * Syntax:   
  *   test_message ( :smtp / :mailbox <mailbox: string> ) <index: number>
@@ -41,6 +48,25 @@ const struct sieve_command_def cmd_test_message = {
 	NULL 
 };
 
+/* Test_message_print command
+ *
+ * Syntax:   
+ *   test_message_print
+ */
+
+static bool cmd_test_message_print_generate
+	(const struct sieve_codegen_env *cgenv, struct sieve_command *cmd);
+
+const struct sieve_command_def cmd_test_message_print = { 
+	"test_message_print", 
+	SCT_COMMAND, 
+	0, 0, FALSE, FALSE,
+	NULL, NULL, NULL, NULL,
+	cmd_test_message_print_generate
+	, NULL
+};
+
+
 /* 
  * Operations
  */ 
@@ -75,6 +101,21 @@ const struct sieve_operation_def test_message_mailbox_operation = {
 	cmd_test_message_mailbox_operation_execute 
 };
 
+/* Test_message_print operation */
+
+static bool cmd_test_message_print_operation_dump
+	(const struct sieve_dumptime_env *denv, sieve_size_t *address);
+static int cmd_test_message_print_operation_execute
+	(const struct sieve_runtime_env *renv, sieve_size_t *address);
+
+const struct sieve_operation_def test_message_print_operation = { 
+	"TEST_MESSAGE_PRINT",
+	&testsuite_extension, 
+	TESTSUITE_OPERATION_TEST_MESSAGE_PRINT,
+	cmd_test_message_print_operation_dump, 
+	cmd_test_message_print_operation_execute 
+};
+
 /*
  * Compiler context data
  */
@@ -254,6 +295,15 @@ static bool cmd_test_message_generate
 	return TRUE;
 }
 
+static bool cmd_test_message_print_generate
+(const struct sieve_codegen_env *cgenv, struct sieve_command *cmd)
+{	
+	/* Emit operation */
+	sieve_operation_emit
+		(cgenv->sblock, cmd->ext, &test_message_print_operation);
+	return TRUE;
+}
+
 /* 
  * Code dump
  */
@@ -292,6 +342,15 @@ static bool cmd_test_message_mailbox_operation_dump
 		sieve_opr_number_dump(denv, address, "index");
 }
 
+static bool cmd_test_message_print_operation_dump
+(const struct sieve_dumptime_env *denv, sieve_size_t *address ATTR_UNUSED)
+{
+	sieve_code_dumpf(denv, "TEST_MESSAGE_PRINT");
+
+	return TRUE;
+}
+
+
 /*
  * Intepretation
  */
@@ -420,6 +479,34 @@ static int cmd_test_message_mailbox_operation_execute
 	return SIEVE_EXEC_OK;
 }
 
+static int cmd_test_message_print_operation_execute
+(const struct sieve_runtime_env *renv, sieve_size_t *address ATTR_UNUSED)
+{
+	struct mail *mail = sieve_message_get_mail(renv->msgctx);
+	struct istream *input;
+	const unsigned char *data;
+	size_t size;
+	int ret;
+
+	if (mail_get_stream(mail, NULL, NULL, &input) < 0) {
+		sieve_runtime_error(renv, NULL,
+			"test_message_print: failed to read current message");
+		return SIEVE_EXEC_OK;
+	}
+
+	printf("\n--MESSAGE: \n");
+		
+	/* Pipe the message to the outgoing SMTP transport */
+	while ((ret=i_stream_read_data(input, &data, &size, 0)) > 0) {
+		write(1, data, size);
+		i_stream_skip(input, size);
+	}
+	printf("\n--MESSAGE--\n");
+	
+	return SIEVE_EXEC_OK;
+}
+
+
 
 
 
diff --git a/src/testsuite/ext-testsuite.c b/src/testsuite/ext-testsuite.c
index 4d3ea014eeb3ddf57164fb8dbdea409a12a12814..3da72a14360765e1995f3d9bc8a0fb8b8cfa08f0 100644
--- a/src/testsuite/ext-testsuite.c
+++ b/src/testsuite/ext-testsuite.c
@@ -69,6 +69,7 @@ const struct sieve_operation_def *testsuite_operations[] = {
 	&test_result_print_operation,
 	&test_message_smtp_operation,
 	&test_message_mailbox_operation,
+	&test_message_print_operation,
 	&test_mailbox_create_operation,
 	&test_mailbox_delete_operation,
 	&test_binary_load_operation,
@@ -125,6 +126,7 @@ static bool ext_testsuite_validator_load
 	sieve_validator_register_command(valdtr, ext, &cmd_test_result_print);
 	sieve_validator_register_command(valdtr, ext, &cmd_test_result_reset);
 	sieve_validator_register_command(valdtr, ext, &cmd_test_message);
+	sieve_validator_register_command(valdtr, ext, &cmd_test_message_print);
 	sieve_validator_register_command(valdtr, ext, &cmd_test_mailbox_create);
 	sieve_validator_register_command(valdtr, ext, &cmd_test_mailbox_delete);
 	sieve_validator_register_command(valdtr, ext, &cmd_test_binary_load);
diff --git a/src/testsuite/testsuite-common.h b/src/testsuite/testsuite-common.h
index e80b4106b6e14ffe2f4f11b11db5ac7769bb7e63..f4ec7499db4c5080a3a988d6dd6b79ce9d0f0ca3 100644
--- a/src/testsuite/testsuite-common.h
+++ b/src/testsuite/testsuite-common.h
@@ -57,6 +57,7 @@ extern const struct sieve_command_def cmd_test_set;
 extern const struct sieve_command_def cmd_test_result_reset;
 extern const struct sieve_command_def cmd_test_result_print;
 extern const struct sieve_command_def cmd_test_message;
+extern const struct sieve_command_def cmd_test_message_print;
 extern const struct sieve_command_def cmd_test_mailbox;
 extern const struct sieve_command_def cmd_test_mailbox_create;
 extern const struct sieve_command_def cmd_test_mailbox_delete;
@@ -96,6 +97,7 @@ enum testsuite_operation_code {
 	TESTSUITE_OPERATION_TEST_RESULT_PRINT,
 	TESTSUITE_OPERATION_TEST_MESSAGE_SMTP,
 	TESTSUITE_OPERATION_TEST_MESSAGE_MAILBOX,
+	TESTSUITE_OPERATION_TEST_MESSAGE_PRINT,
 	TESTSUITE_OPERATION_TEST_MAILBOX_CREATE,
 	TESTSUITE_OPERATION_TEST_MAILBOX_DELETE,
 	TESTSUITE_OPERATION_TEST_BINARY_LOAD,
@@ -119,6 +121,7 @@ extern const struct sieve_operation_def test_result_reset_operation;
 extern const struct sieve_operation_def test_result_print_operation;
 extern const struct sieve_operation_def test_message_smtp_operation;
 extern const struct sieve_operation_def test_message_mailbox_operation;
+extern const struct sieve_operation_def test_message_print_operation;
 extern const struct sieve_operation_def test_mailbox_create_operation;
 extern const struct sieve_operation_def test_mailbox_delete_operation;
 extern const struct sieve_operation_def test_binary_load_operation;