Skip to content

Commit

Permalink
#3385 - disable email with hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
abrookbanks committed Mar 18, 2024
1 parent adcf952 commit 5b6f507
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions classes/mailer.class.php
Expand Up @@ -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,
Expand Down

0 comments on commit 5b6f507

Please sign in to comment.