コード例 #1
0
ファイル: mail.php プロジェクト: HLitmus/WebApp
 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));
 }
コード例 #2
0
ファイル: EmailTest.php プロジェクト: taz77/sendgrid-php-ng
 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');
 }
コード例 #3
0
 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()));
 }
コード例 #4
0
ファイル: Email.php プロジェクト: enginethemes/et_mailing
 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");
 }
コード例 #5
0
 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");
 }