Beispiel #1
0
 public static function notify($options)
 {
     $body = self::_body($options);
     $emails = isset($options["emails"]) ? $options["emails"] : array($options["user"]->email);
     $delivery = isset($options["delivery"]) ? $options["delivery"] : "sendgrid";
     switch ($delivery) {
         default:
             $sendgrid = self::_sendgrid();
             $email = new \SendGrid\Email();
             $email->setSmtpapiTos($emails)->setFrom('*****@*****.**')->setFromName("HealthLitmus Team")->setSubject($options["subject"])->setHtml($body);
             if (isset($options["attachment"])) {
                 $email->setAttachment($options["attachment"]);
             }
             $sendgrid->send($email);
             break;
     }
     self::log(implode(",", $emails));
 }
Beispiel #2
0
 public function testToWebFormatWithSetAttachmentAndCid()
 {
     $email = new \SendGrid\Email();
     $email->setAttachment('./gif.gif', NULL, 'sample-cid');
     $f = pathinfo('./gif.gif');
     $json = $email->toWebFormat();
     $this->assertEquals($json['files']['gif.gif'], $f['dirname'] . '/' . $f['basename']);
     $this->assertEquals($json['content[gif.gif]'], 'sample-cid');
 }
 public function testSetAttachmentCustomFilename()
 {
     $email = new SendGrid\Email();
     //Setting an attachment removes all other files
     $email->setAttachment("only_attachment.sad", "different");
     $attachments = $email->getAttachments();
     $this->assertEquals(1, count($attachments));
     $this->assertEquals($attachments[0]['custom_filename'], 'different');
     //Remove an attachment
     $email->removeAttachment("only_attachment.sad");
     $this->assertEquals(0, count($email->getAttachments()));
 }
Beispiel #4
0
 public function testToWebFormatWithSetAttachmentAndCid()
 {
     $email = new SendGrid\Email();
     $email->setAttachment('./gif.gif', null, 'sample-cid');
     $json = $email->toWebFormat();
     // php 5.5 works differently. @filename has been deprecated for CurlFile in 5.5
     if (class_exists('CurlFile')) {
         $content = new \CurlFile('./gif.gif', 'gif', 'gif');
         $this->assertEquals($json["files[gif.gif]"], $content);
     } else {
         $this->assertEquals($json["files[gif.gif]"], "@./gif.gif");
     }
     $this->assertEquals($json["content[gif.gif]"], "sample-cid");
 }
 public function testToWebFormatWithSetAttachmentAndCid()
 {
     $email = new SendGrid\Email();
     $email->setAttachment('./gif.gif', null, 'sample-cid');
     $json = $email->toWebFormat();
     $this->assertEquals($json["files[gif.gif]"], "@./gif.gif");
     $this->assertEquals($json["content[gif.gif]"], "sample-cid");
 }