From 5c78747f5c10e903ef3d6c23e32574cec29571d5 Mon Sep 17 00:00:00 2001
From: "florian.azizian" <florian.azizian@maarch.org>
Date: Thu, 11 Jan 2018 17:22:28 +0100
Subject: [PATCH] FIX #6955 save email draft even if there is no subject or no
 recipient

---
 modules/sendmail/sendmail_ajax_content.php | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/modules/sendmail/sendmail_ajax_content.php b/modules/sendmail/sendmail_ajax_content.php
index f98f59364de..4d24c39506a 100755
--- a/modules/sendmail/sendmail_ajax_content.php
+++ b/modules/sendmail/sendmail_ajax_content.php
@@ -194,13 +194,14 @@ switch ($mode) {
             $error = $request->wash_html(_INCORRECT_SENDER,'NONE');
             $status = 1;
         } else {
-            if (isset($_SESSION['adresses']['to']) && count($_SESSION['adresses']['to']) > 0 ) {
-                if (!empty($_REQUEST['object'])) {
-                    // print_r($_REQUEST);exit;
+            if ((isset($_SESSION['adresses']['to']) && count($_SESSION['adresses']['to']) > 0) || $_REQUEST['for'] == 'save') {
+                if (!empty($_REQUEST['object']) || $_REQUEST['for'] == 'save') {
                     
                     //Check adress for to
-                    $to =  join(',', $_SESSION['adresses']['to']);
-                    $error = $sendmail_tools->CheckEmailAdress($to);
+                    if(!empty($_SESSION['adresses']['to'])){
+                        $to =  join(',', $_SESSION['adresses']['to']);
+                        $error = $sendmail_tools->CheckEmailAdress($to);
+                    }
                     
                     if (empty($error)) {
                         
@@ -334,13 +335,14 @@ switch ($mode) {
                 $error = $request->wash_html(_INCORRECT_SENDER,'NONE');
                 $status = 1;
             } else {
-                if (isset($_SESSION['adresses']['to']) && count($_SESSION['adresses']['to']) > 0 ) {
-                    if (!empty($_REQUEST['object'])) {
-                        // print_r($_REQUEST);exit;
+                if ((isset($_SESSION['adresses']['to']) && count($_SESSION['adresses']['to']) > 0) || $_REQUEST['for'] == 'save') {
+                    if (!empty($_REQUEST['object']) || $_REQUEST['for'] == 'save') {
                         
                         //Check adress for to
-                        $to =  join(',', $_SESSION['adresses']['to']);
-                        $error = $sendmail_tools->CheckEmailAdress($to);
+                        if(!empty($_SESSION['adresses']['to'])){
+                            $to =  join(',', $_SESSION['adresses']['to']);
+                            $error = $sendmail_tools->CheckEmailAdress($to);
+                        }
                         
                         if (empty($error)) {
                             
-- 
GitLab