@@ -39,6 +39,28 @@ public function mail($to, $subject, $text, $from, $filepath = '', $filetype = 'a
3939
4040 if ($ conf ['demo_mode ' ] == true ) $ app ->error ("Mail sending disabled in demo mode. " );
4141
42+ $ app ->uses ('getconf,ispcmail ' );
43+ $ mail_config = $ app ->getconf ->get_global_config ('mail ' );
44+ if ($ mail_config ['smtp_enabled ' ] == 'y ' ) {
45+ $ mail_config ['use_smtp ' ] = true ;
46+ $ app ->ispcmail ->setOptions ($ mail_config );
47+ }
48+ $ app ->ispcmail ->setSender ($ from );
49+ $ app ->ispcmail ->setSubject ($ subject );
50+ $ app ->ispcmail ->setMailText ($ text );
51+
52+ if ($ filepath != '' ) {
53+ if (!file_exists ($ filepath )) $ app ->error ("Mail attachement does not exist " .$ filepath );
54+ $ app ->ispcmail ->readAttachFile ($ filepath );
55+ }
56+
57+ if ($ cc != '' ) $ app ->ispcmail ->setHeader ('Cc ' , $ cc );
58+ if ($ bcc != '' ) $ app ->ispcmail ->setHeader ('Bcc ' , $ bcc );
59+
60+ $ app ->ispcmail ->send ($ to );
61+ $ app ->ispcmail ->finish ();
62+
63+ /* left in here just for the case...
4264 if($filepath != '') {
4365 if(!file_exists($filepath)) $app->error("Mail attachement does not exist ".$filepath);
4466
@@ -83,7 +105,7 @@ public function mail($to, $subject, $text, $from, $filepath = '', $filetype = 'a
83105 $subject = "=?utf-8?B?".base64_encode($subject)."?=";
84106 mail($to, $subject, $text, $header);
85107 }
86-
108+ */
87109 return true ;
88110 }
89111
0 commit comments