當前位置: 首頁>>代碼示例>>PHP>>正文


PHP SendGrid::send方法代碼示例

本文整理匯總了PHP中SendGrid::send方法的典型用法代碼示例。如果您正苦於以下問題:PHP SendGrid::send方法的具體用法?PHP SendGrid::send怎麽用?PHP SendGrid::send使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SendGrid的用法示例。


在下文中一共展示了SendGrid::send方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: sendEmail

 public function sendEmail($mail)
 {
     $setting = Setting::find()->where(['id' => 1])->one();
     $username = $setting->sendgridUsername;
     $password = $setting->sendgridPassword;
     $mail_admin = $setting->emailAdmin;
     $sendgrid = new \SendGrid($username, $password, array("turn_off_ssl_verification" => true));
     $email = new \SendGrid\Email();
     $subject = 'Registrasi Berhasil';
     $body = 'Thanks ' . $this->username . ',';
     $body .= "\n";
     $body .= "Registrasi anda berhasil, kami akan segera mereview kembali registrasi anda. \n";
     $body .= "Thanks, \n";
     $body .= Yii::$app->name;
     $body_message = $this->template($subject, $body, $logo);
     $email->addTo($mail)->setFrom($mail_admin)->setSubject('Registrasi berhasil')->setHtml($body_message)->addCategory("registrasi");
     $response = $sendgrid->send($email);
     //return $response;
     //send whatsapp
     if ($setting->whatsappNumber && $setting->whatsappPassword) {
         $number = $setting->whatsappNumber;
         $app = Yii::$app->name;
         $password = $setting->whatsappPassword;
         $w = new WhatsApp($number, $app, $password);
         $w->send($setting->whatsappSend, $body);
     }
 }
開發者ID:sintret,項目名稱:yii2-basic,代碼行數:27,代碼來源:SignupForm.php

示例2: send

 public function send(MessageInterface $message)
 {
     if (count($message->getToList()) === 0) {
         // TODO FIXED EXCEPTION
         throw new \Exception();
     }
     foreach ($message->getToList() as $email) {
         if (!$this->validateEmail($email)) {
             // TODO FIXED EXCEPTION
             throw new \Exception();
         }
     }
     $sendgrid = new \SendGrid(env("SENDGRID_USERNAME"), env("SENDGRID_PASSWORD"));
     $email = new \SendGrid\Email();
     $email->addTo($message->getToList())->setFrom($message->getFrom())->setSubject($message->getSubject())->setText($message->getTextBody())->setHtml($message->getHtmlBody());
     if (is_array($message->getBccList())) {
         $email->addBcc($message->getBccList());
     }
     $email->setAttachments($message->getAttachments());
     try {
         $sendgrid->send($email);
     } catch (\Exception $e) {
         throw $e;
     }
 }
開發者ID:chatbox-inc,項目名稱:mail,代碼行數:25,代碼來源:Sendgrid.php

示例3: sendEmail

 protected function sendEmail($to, $from, $body, $subject)
 {
     $sendgrid = new SendGrid('fake username2', 'fake password 2');
     $email = new SendGrid\Email($this->username, $this->password);
     $email->addTo($to)->setFrom($from)->setSubject($subject)->setText($body)->setHtml($body);
     return $sendgrid->send($email);
 }
開發者ID:raynaldmo,項目名稱:php-education,代碼行數:7,代碼來源:notify.php

示例4: sendMail

 public function sendMail()
 {
     /* @var $user User */
     $user = User::findOne(['status' => User::STATUS_ACTIVE, 'email' => $this->email]);
     if ($user) {
         if (!User::isPasswordResetTokenValid($user->password_reset_token)) {
             $user->generatePasswordResetToken();
         }
         if ($user->save()) {
             $setting = Setting::find()->where(['id' => 1])->one();
             $username = $setting->sendgridUsername;
             $password = $setting->sendgridPassword;
             $mail_admin = $setting->emailAdmin;
             $sendgrid = new \SendGrid($username, $password, array("turn_off_ssl_verification" => true));
             $email = new \SendGrid\Email();
             $mail = $user->email;
             //echo $user->email;exit(0);
             $resetLink = \Yii::$app->urlManager->createAbsoluteUrl(['site/reset-password', 'token' => $user->password_reset_token]);
             $body_message = 'Hello ' . Html::encode($user->username) . ', <br>
             Follow the link below to reset your password:  <br>
             ' . Html::a(Html::encode($resetLink), $resetLink);
             $email->addTo($user->email)->setFrom($mail_admin)->setSubject('Password reset for ' . \Yii::$app->name)->setHtml($body_message);
             $response = $sendgrid->send($email);
             //print_r($response); exit(0);
             return $response;
         }
     }
     return false;
 }
開發者ID:sintret,項目名稱:yii2-basic,代碼行數:29,代碼來源:PasswordResetRequestForm.php

示例5: actionSendChat

 public function actionSendChat()
 {
     if (!empty($_POST)) {
         echo \sintret\chat\ChatRoom::sendChat($_POST);
         $message = Yii::$app->user->identity->username . ' : ' . $_POST['message'];
         $pos = strpos($message, "@");
         $setting = \app\models\Setting::findOne(1);
         if ($pos !== FALSE) {
             // $w = new WhatsApp($number, $app, $password);
             $usernameSendgrid = $setting->sendgridUsername;
             $passwordSendgrid = $setting->sendgridPassword;
             $users = \app\models\User::find()->where(['status' => \app\models\User::STATUS_ACTIVE])->all();
             foreach ($users as $model) {
                 $aprot = '@' . strtolower($model->username);
                 if (strpos($message, $aprot) !== false) {
                     $sendgrid = new \SendGrid($usernameSendgrid, $passwordSendgrid, array("turn_off_ssl_verification" => true));
                     $email = new \SendGrid\Email();
                     $email->addTo($model->email)->setFrom($setting->emailSupport)->setSubject('Chat from ' . $setting->applicationName)->setHtml($message);
                     $sendgrid->send($email);
                 } else {
                 }
             }
         }
     }
 }
開發者ID:sintret,項目名稱:yii2-basic-sintret,代碼行數:25,代碼來源:AjaxController.php

示例6: sendMail

 /**
  * @param string $from
  * @param string $to
  * @param string $message
  * @param string $subject
  *
  * @return \stdClass
  */
 protected function sendMail($from, $to, $message, $subject)
 {
     $sendGrind = new \SendGrid($this->username, $this->password);
     $email = new Email();
     $email->addTo($from)->addTo($to)->setSubject($subject)->setText(strip_tags($message))->setHtml($message);
     return $sendGrind->send($email);
 }
開發者ID:kisphp,項目名稱:PhpDesignPatterns,代碼行數:15,代碼來源:NotifyAdapter.php

示例7: sendEmail

function sendEmail($to, $subject, $message)
{
    $sendgrid = new SendGrid('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');
    $email = new SendGrid\Email();
    $email->addTo($to)->setFrom('noreply@ilmarching.com')->setSubject($subject)->setText('text')->setHtml($message);
    $sendgrid->send($email);
}
開發者ID:mover5,項目名稱:imobackup,代碼行數:7,代碼來源:ilmarching_sendgrid.php

示例8: send_email

function send_email($to_address, $subject, $text, $hmtl)
{
    global $SENDGRID_USER, $SENDGRID_PASS;
    $sendgrid = new SendGrid($SENDGRID_USER, $SENDGRID_PASS);
    $email = new SendGrid\Email();
    $email->addTo($to_address)->setFrom('contact@getschedule.ninja')->setSubject($subject)->setText($text)->setHtml($html);
    $sendgrid->send($email);
}
開發者ID:ssaamm,項目名稱:schedule-ninja,代碼行數:8,代碼來源:handle_sendgrid.php

示例9: testSendResponseWithSslOptionFalse

 public function testSendResponseWithSslOptionFalse()
 {
     $sendgrid = new SendGrid("foo", "bar", array("switch_off_ssl_verification" => true));
     $email = new SendGrid\Email();
     $email->setFrom('p1@mailinator.com')->setSubject('foobar subject')->setText('foobar text')->addTo('p1@mailinator.com')->addAttachment('./text');
     $response = $sendgrid->send($email);
     $this->assertEquals("Bad username / password", $response->errors[0]);
 }
開發者ID:enginethemes,項目名稱:et_mailing,代碼行數:8,代碼來源:SendGrid.php

示例10: sendMail

 /**
  * Simple function to send and e-mail
  * @param string $dest Mail destination
  * @param string $title Mail title
  * @param string $body Mail body
  */
 public static function sendMail($dest, $title, $body)
 {
     require_once 'vendor/autoload.php';
     include 'values/mailCredentials.php';
     $sendgrid = new SendGrid($mail_user, $mail_password);
     $email = new SendGrid\Email();
     $email->addTo($dest)->setFrom('tripzor.noreply@tripzor.org')->setSubject($title)->setText($body);
     $response = $sendgrid->send($email);
     return $response->getCode() == 200;
 }
開發者ID:piax93,項目名稱:tripzor_server,代碼行數:16,代碼來源:MailSender.php

示例11: _sendWithSendgrid

 /**
  * Sends an email using the Sendgrid Email API.
  *
  * @return void
  */
 protected function _sendWithSendgrid()
 {
     try {
         $sendgrid = new \SendGrid(Settings::config()->transport_token);
         $email = new \SendGrid\Email();
         $email->addTo($this->email)->setFrom(Settings::config()->transport_email)->setSubject($this->subject)->setHtml($this->message);
         $sendgrid->send($email);
     } catch (\SendGrid\Exception $e) {
         Debugger::log($e);
     }
 }
開發者ID:ByteKing,項目名稱:Main,代碼行數:16,代碼來源:email.php

示例12: send

 public function send()
 {
     $config = \Drupal::config('spectrum.settings');
     $api_key = $config->get('sendgrid_api_key');
     if (!strlen($api_key)) {
         \Drupal::logger('spectrum')->error('Spectrum Error: API Key cannot be blank.');
         return NULL;
     }
     $this->email->setSubject($this->template->renderBlock('subject', $this->templateParameters));
     $this->email->setText($this->template->renderBlock('body_text', $this->templateParameters));
     $this->email->setHtml($this->template->renderBlock('body_html', $this->templateParameters));
     $sendgrid = new \SendGrid($api_key);
     $sendgrid->send($this->email);
 }
開發者ID:pjcarly,項目名稱:drupal8-spectrum,代碼行數:14,代碼來源:Email.php

示例13: sendEmail

 static function sendEmail($to, $from, $subject, $message, $cc)
 {
     //User credentials
     $sendgrid_username = "atushabe";
     $sendgrid_password = "atushabe123";
     //Set SendGrid Parameters
     $sendgrid = new SendGrid($sendgrid_username, $sendgrid_password, array("turn_off_ssl_verification" => true));
     //instantiate library class
     $email = new SendGrid\Email();
     //Set variables(to,cc,from,subject, message & headers for email) and send email
     $email->addTo($to)->addTo($cc)->setFrom($from)->setSubject($subject)->setCc($cc)->setHtml($message)->addHeader('X-Sent-Using', 'SendGrid-API')->addHeader('X-Transport', 'web');
     //Wait for email response
     $response = $sendgrid->send($email);
 }
開發者ID:andrewolobo,項目名稱:adMailer,代碼行數:14,代碼來源:emailer.php

示例14: deliver

 public function deliver($message)
 {
     $sendgrid = new \SendGrid($this->username, $this->password, $this->options);
     $email = new \SendGrid\Email();
     $to = $message->getTo();
     if (is_array($to)) {
         foreach ($to as $rcpt) {
             $email->addTo($rcpt);
         }
     } else {
         $email->addTo($to);
     }
     $email->setFrom($this->from)->setFromName($this->from_name)->setSubject($message->getSubject())->setText($message->renderText())->setHtml($message->renderHtml());
     $sendgrid->send($email);
 }
開發者ID:bparks,項目名稱:pails-actionmailer,代碼行數:15,代碼來源:SendgridTransport.php

示例15: sendEmail

 protected function sendEmail($to, $subj, $text, $html = null)
 {
     $email = new \SendGrid\Email();
     $email->addCategory($subj);
     $email->addTo($to);
     $email->setFrom('hello@edgeconf.com');
     $email->setFromName('Edge conf');
     $email->setSubject($subj);
     $email->setText($text);
     if ($html) {
         $emogrifier = new \Pelago\Emogrifier($html, file_get_contents(realpath(__DIR__ . '/../../../public/css/email.css')));
         $email->setHtml($emogrifier->emogrify());
     }
     $sendgrid = new \SendGrid($this->app->config->sendgrid->username, $this->app->config->sendgrid->password);
     $resp = $sendgrid->send($email);
 }
開發者ID:phamann,項目名稱:edgeconf,代碼行數:16,代碼來源:BaseController.php


注:本文中的SendGrid::send方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。