@@ -812,7 +812,7 @@ public function delOldRecords($type, $serverId) {
812812 }
813813
814814 public function send_notification_email ($ template , $ placeholders , $ recipients ) {
815- global $ conf ;
815+ global $ app , $ conf ;
816816
817817 if (!is_array ($ recipients ) || count ($ recipients ) < 1 ) return false ;
818818 if (!is_array ($ placeholders )) $ placeholders = array ();
@@ -829,6 +829,7 @@ public function send_notification_email($template, $placeholders, $recipients) {
829829
830830 //* get mail headers, subject and body
831831 $ mailHeaders = '' ;
832+ $ mailFrom = '' ;
832833 $ mailBody = '' ;
833834 $ mailSubject = '' ;
834835 $ inHeader = true ;
@@ -844,6 +845,16 @@ public function send_notification_email($template, $placeholders, $recipients) {
844845 $ mailSubject = trim ($ parts [1 ]);
845846 continue ;
846847 }
848+ if (strtolower ($ parts [0 ]) == 'From ' ) {
849+ $ mailFrom = trim ($ parts [1 ]);
850+ continue ;
851+ }
852+ if (strtolower ($ parts [0 ]) == 'Cc ' ) {
853+ if (! in_array (trim ($ parts [1 ]), $ recipients )) {
854+ $ recipients [] = trim ($ parts [1 ]);
855+ }
856+ continue ;
857+ }
847858 unset($ parts );
848859 $ mailHeaders .= trim ($ lines [$ l ]) . "\n" ;
849860 } else {
@@ -854,18 +865,14 @@ public function send_notification_email($template, $placeholders, $recipients) {
854865
855866 //* Replace placeholders
856867 $ mailHeaders = strtr ($ mailHeaders , $ placeholders );
868+ $ mailFrom = strtr ($ mailFrom , $ placeholders );
857869 $ mailSubject = strtr ($ mailSubject , $ placeholders );
858870 $ mailBody = strtr ($ mailBody , $ placeholders );
859871
860872 for ($ r = 0 ; $ r < count ($ recipients ); $ r ++) {
861- $ app ->functions ->mail ($ recipients [$ r ], $ mailSubject , $ mailBody , $ mailHeaders );
873+ $ app ->functions ->mail ($ recipients [$ r ], $ mailSubject , $ mailBody , $ mailFrom );
862874 }
863875
864- unset($ mailSubject );
865- unset($ mailHeaders );
866- unset($ mailBody );
867- unset($ lines );
868-
869876 return true ;
870877 }
871878
0 commit comments