From b44b4d32e12fde2cc763bc4998e9ce18585c4b6d Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Fri, 05 Mar 2010 04:34:03 -0500
Subject: [PATCH] Allow outgoing_message_headers hook to abort message sending

---
 program/steps/mail/sendmail.inc |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index abd4209..acff62d 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -344,6 +344,18 @@
 if (!empty($CONFIG['useragent']))
   $headers['User-Agent'] = $CONFIG['useragent'];
 
+// exec hook for header checking and manipulation
+$data = $RCMAIL->plugins->exec_hook('outgoing_message_headers', array('headers' => $headers));
+
+// sending aborted by plugin
+if ($data['abort'] && !$savedraft) {
+  $OUTPUT->show_message($data['message'] ? $data['message'] : 'sendingfailed');
+  $OUTPUT->send('iframe');
+}
+else
+  $headers = $data['headers'];
+
+
 $isHtmlVal = strtolower(get_input_value('_is_html', RCUBE_INPUT_POST));
 $isHtml = ($isHtmlVal == "1");
 
@@ -473,9 +485,6 @@
 $MAIL_MIME->setParam('head_charset', $message_charset);
 $MAIL_MIME->setParam('html_charset', $message_charset);
 $MAIL_MIME->setParam('text_charset', $message_charset);
-
-$data = $RCMAIL->plugins->exec_hook('outgoing_message_headers', array('headers' => $headers));
-$headers = $data['headers'];
 
 // encoding subject header with mb_encode provides better results with asian characters
 if (function_exists('mb_encode_mimeheader'))

--
Gitblit v1.9.1