+ // Hard coded. Should be an option on the mail config.+ $sendgrid = true;+ if ($sendgrid) {+ $ost->logDebug("Sending with sendgrid",$this->getFromAddress());+ + $mail = new SendGrid\Mail();+ + $from = new SendGrid\Email(preg_replace("/(\r\n|\r|\n)/s",'', trim($this->getEmail()->getName())), $this->getEmail()->getEmail());+ $mail->setFrom($from);+ + $mail->setSubject($subject);+ + if ($isHtml)+ $content = new SendGrid\Content("text/html", $message);+ else+ $content = new SendGrid\Content("text/plain", $message);+ $mail->addContent($content);+ + $personalization = new SendGrid\Personalization();+ $to = new SendGrid\Email(preg_replace("/(\r\n|\r|\n)/s",'', trim($toName)), $toEmail);+ $personalization->addTo($to);+ + foreach ($headers as $key => $value){+ $ost->logDebug($key,$value);+ if ($key != "To" && $key != "From" && $key != "Subject" && $key != "Content-Type")v $personalization->addHeader($key,$value);+ }+ $mail->addPersonalization($personalization);+