From 5b6f5070ea35183418470e6a4713d1404a6d565c Mon Sep 17 00:00:00 2001 From: Al Brookbanks Date: Mon, 18 Mar 2024 17:03:31 +0000 Subject: [PATCH] #3385 - disable email with hooks --- classes/mailer.class.php | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/classes/mailer.class.php b/classes/mailer.class.php index 3ba63c364..a54698ef0 100755 --- a/classes/mailer.class.php +++ b/classes/mailer.class.php @@ -254,24 +254,27 @@ public function sendEmail($email = false, $contents = array(), $template_id = fa } // Send email - if($this->_method=='sendgrid') { - $this->_sendgrid->setFrom($this->From, $this->FromName); - $this->_sendgrid->setSubject($this->Subject); - foreach($send_grid_to as $t) { - $this->_sendgrid->addTo($t); - } - $this->_sendgrid->addContent("text/plain", $this->_text); - $this->_sendgrid->addContent("text/html", $this->_html); - $sendgrid = new \SendGrid($this->_sendgrid_key); - try { - $response = $sendgrid->send($this->_sendgrid); - $result = in_array($response->statusCode(), array(200, 202)) ? true : false; - } catch (Exception $e) { - $this->ErrorInfo = $e->getMessage(); + if(!isset($disable_send) || !$disable_send) { + if($this->_method=='sendgrid') { + $this->_sendgrid->setFrom($this->From, $this->FromName); + $this->_sendgrid->setSubject($this->Subject); + foreach($send_grid_to as $t) { + $this->_sendgrid->addTo($t); + } + $this->_sendgrid->addContent("text/plain", $this->_text); + $this->_sendgrid->addContent("text/html", $this->_html); + $sendgrid = new \SendGrid($this->_sendgrid_key); + try { + $response = $sendgrid->send($this->_sendgrid); + $result = in_array($response->statusCode(), array(200, 202)) ? true : false; + } catch (Exception $e) { + $this->ErrorInfo = $e->getMessage(); + } + } else { + $result = $this->Send(); } - } else { - $result = $this->Send(); } + // Log email $email_data = array( 'subject' => $this->Subject,