/** * Send the mail. * * @param Midas_Mail $mail mail instance * @throws Midas_Service_AppEngine_Exception */ public function sendMail(Midas_Mail $mail) { if (is_null($this->_client)) { $this->_client = new \google\appengine\api\mail\Message(); } $this->_client->addBcc($mail->getBcc()); $this->_client->addCc($mail->getCc()); $this->_client->addTo($mail->getTo()); $this->_client->setHtmlBody($mail->getBodyHtml(true)); $this->_client->setReplyTo($mail->getReplyTo()); $this->_client->setSender($mail->getFrom()); $this->_client->setSubject($mail->getSubject()); $this->_client->setTextBody($mail->getBodyText(true)); try { $this->_client->send(); } catch (\Exception $exception) { throw new Midas_Service_AppEngine_Exception($exception); } }
/** * Send the mail. * * @param Midas_Mail $mail mail instance * @throws Midas_Service_SendGrid_Exception */ public function sendMail(Midas_Mail $mail) { if (is_null($this->_client)) { $this->_client = new \SendGrid($this->_user, $this->_key, $this->_config); } $email = new \SendGrid\Email(); $email->setBccs($mail->getBcc()); $email->setCcs($mail->getCc()); $email->setHtml($mail->getBodyHtml(true)); $email->setFrom($mail->getFrom()); $email->setReplyTo($mail->getReplyTo()); $email->setSubject($mail->getSubject()); $email->setText($mail->getBodyText(true)); $email->setTos($mail->getTo()); try { $this->_client->send($email); } catch (\SendGrid\Exception $exception) { throw new Midas_Service_SendGrid_Exception('Could not send mail'); } }