diff --git a/modules/imap/functions.php b/modules/imap/functions.php
index d05f7fbaee..f3033a2dc0 100644
--- a/modules/imap/functions.php
+++ b/modules/imap/functions.php
@@ -1023,6 +1023,7 @@ function format_list_headers($mod) {
$section = ' '.$mod->html_safe($name).': ';
foreach ($vals['email'] as $v) {
$sources[] = ''.$mod->trans('email').'';
}
foreach ($vals['links'] as $v) {
diff --git a/modules/smtp/modules.php b/modules/smtp/modules.php
index a186d6d7a8..9c1bf4a547 100644
--- a/modules/smtp/modules.php
+++ b/modules/smtp/modules.php
@@ -411,7 +411,6 @@ public function process() {
*/
class Hm_Handler_process_compose_form_submit extends Hm_Handler_Module {
public function process() {
-
/* not sending */
if (!array_key_exists('smtp_send', $this->request->post)) {
return;
@@ -511,6 +510,19 @@ public function process() {
}
}
+/**
+ * Determine if composer_from is set
+ * @subpackage smtp/handler
+ */
+class Hm_Handler_smtp_from_replace extends Hm_Handler_Module {
+ public function process()
+ {
+ if (array_key_exists('compose_from', $this->request->get)) {
+ $this->out('compose_from', $this->request->get['compose_from']);
+ }
+ }
+}
+
/**
* Determine if auto-bcc is active
* @subpackage smtp/handler
@@ -611,6 +623,8 @@ protected function output() {
$html = $this->get('smtp_compose_type', 0);
$msg_path = $this->get('list_path', '');
$msg_uid = $this->get('uid', '');
+ $from = $this->get('compose_from');
+
if (!$msg_path) {
$msg_path = $this->get('compose_msg_path', '');
}
@@ -693,6 +707,13 @@ protected function output() {
foreach ($files as $file) {
$res .= format_attachment_row($file, $this);
}
+
+ // If compose_from GET parameter is set, force $recip replacement.
+ // This ensures any module can force the selected dropdown SMTP server
+ if ($from) {
+ $recip = $from;
+ }
+
$res .= ''.
smtp_server_dropdown($this->module_output(), $this, $recip, $smtp_id).
''.
@@ -910,7 +931,7 @@ function smtp_server_dropdown($data, $output_mod, $recip, $selected_id=false) {
if (!$selected && $selected_id !== false && $id == $selected_id) {
$selected = $id;
}
- elseif (!$selected && $recip && trim($recip) == trim($vals['user'])) {
+ if (!$selected && $recip && trim($recip) == trim($vals['user'])) {
$selected = $id;
}
}
diff --git a/modules/smtp/setup.php b/modules/smtp/setup.php
index fb47791eca..6c7dcbe788 100644
--- a/modules/smtp/setup.php
+++ b/modules/smtp/setup.php
@@ -7,6 +7,7 @@
add_module_to_all_pages('handler', 'smtp_default_server', true, 'smtp', 'load_user_data', 'after');
add_handler('compose', 'load_smtp_reply_to_details', true, 'smtp', 'load_user_data', 'after');
+add_handler('compose', 'smtp_from_replace', true, 'smtp', 'load_user_data', 'after');
add_handler('compose', 'load_smtp_servers_from_config', true, 'smtp', 'load_smtp_reply_to_details', 'after');
add_handler('compose', 'add_smtp_servers_to_page_data', true, 'smtp', 'load_smtp_servers_from_config', 'after');
add_handler('compose', 'process_compose_form_submit', true, 'smtp', 'load_smtp_servers_from_config', 'after');
@@ -97,6 +98,7 @@
'draft_id' => FILTER_VALIDATE_INT,
'compose_to' => FILTER_SANITIZE_STRING,
'mailto_uri' => FILTER_SANITIZE_STRING,
+ 'compose_from' => FILTER_SANITIZE_STRING
),
'allowed_output' => array(
'file_details' => array(FILTER_UNSAFE_RAW, false),