@@ -26,7 +26,7 @@ class MailManager extends AbstractManager
2626 * @Param string $subject -> subject of mail
2727 * @Param string $body -> html content with data
2828 */
29- public function sendMailSMTP (string $ receiver , string $ subject , string $ body , ?string $ senderMail , ?string $ senderName ): void
29+ public function sendMailSMTP (string $ receiver , string $ subject , string $ body , ?string $ senderMail , ?string $ senderName ): bool
3030 {
3131 $ config = MailModel::getInstance ()->getConfig ();
3232
@@ -66,39 +66,46 @@ public function sendMailSMTP(string $receiver, string $subject, string $body, ?s
6666 $ mail ->Body = $ body . '<br> ' . $ config ?->getFooter();
6767
6868 // Send mail
69- $ mail ->send ();
69+ $ status = $ mail ->send ();
70+
71+ if (!$ status ) {
72+ error_log ("Message could not be sent. Mailer Error: $ mail ->ErrorInfo " );
73+ }
74+
75+ return $ status ;
7076 } catch (Exception $ e ) {
7177 echo "Message could not be sent. Mailer Error: $ e " ;
7278 error_log ("Message could not be sent. Mailer Error: $ e " );
79+ return false ;
7380 }
7481 }
7582
7683 /**
7784 * @param string $receiver
7885 * @param string $object
7986 * @param string $body
80- * @return void
87+ * @return bool
8188 * @desc Send mail with the Default php function
8289 */
83- private function sendMailPHP (string $ receiver , string $ object , string $ body ): void
90+ private function sendMailPHP (string $ receiver , string $ object , string $ body ): bool
8491 {
85- mail ($ receiver , $ object , $ body );
92+ return mail ($ receiver , $ object , $ body );
8693 }
8794
8895 /**
8996 * @param string $receiver
9097 * @param string $object
9198 * @param string $body
92- * @return void
99+ * @return bool
93100 * @desc Send mail (SMTP OR PHP MAIL function)
94101 */
95- public function sendMail (string $ receiver , string $ object , string $ body ): void
102+ public function sendMail (string $ receiver , string $ object , string $ body ): bool
96103 {
97104 if (MailModel::getInstance ()->getConfig () !== null && MailModel::getInstance ()->getConfig ()->isEnable ()) {
98- $ this ->sendMailSMTP ($ receiver , $ object , $ body , '' , '' );
99- } else {
100- $ this ->sendMailPHP ($ receiver , $ object , $ body );
105+ return $ this ->sendMailSMTP ($ receiver , $ object , $ body , '' , '' );
101106 }
107+
108+ return $ this ->sendMailPHP ($ receiver , $ object , $ body );
102109 }
103110
104111 /**
0 commit comments