• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP SendGrid类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中SendGrid的典型用法代码示例。如果您正苦于以下问题:PHP SendGrid类的具体用法?PHP SendGrid怎么用?PHP SendGrid使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了SendGrid类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: 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


示例2: 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


示例3: 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


示例4: sendEmail

function sendEmail($to, $subject, $message)
{
    $sendgrid = new SendGrid('ilmarching_mail', 'aksld8jc98aisndcasd98ch98273hnd9das8ejncm');
    $email = new SendGrid\Email();
    $email->addTo($to)->setFrom('[email protected]')->setSubject($subject)->setText('text')->setHtml($message);
    $sendgrid->send($email);
}
开发者ID:mover5,项目名称:imobackup,代码行数:7,代码来源:ilmarching_sendgrid.php


示例5: 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


示例6: 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


示例7: wp_send

 /**
  * Override Email send
  *
  * @param   SendGrid\Email  $email      Email object with email info 
  * @param   SendGrid        $sendgrid   Sendgrid object with credentials info
  * @return  array                       Array of results
  */
 function wp_send(SendGrid\Email $email, $sendgrid)
 {
     $form = $email->toWebFormat();
     $form['api_user'] = Sendgrid_Tools::get_username();
     $form['api_key'] = Sendgrid_Tools::get_password();
     $url = $sendgrid->url . $sendgrid->endpoint;
     $files = preg_grep('/files/', array_keys($form));
     if (count($files) > 0) {
         if (in_array('curl', get_loaded_extensions())) {
             $response = $sendgrid->postRequest($sendgrid->endpoint, $form);
             $response = array('body' => $response->raw_body);
         } else {
             update_option('sendgrid_curl_option', 'disabled');
             foreach ($files as $key => $value) {
                 unset($form[$value]);
             }
             $data = array('body' => $form);
             $response = wp_remote_post($url, $data);
         }
     } else {
         $data = array('body' => $form);
         $response = wp_remote_post($url, $data);
     }
     return $response;
 }
开发者ID:linniepinski,项目名称:perssistant,代码行数:32,代码来源:overwrite-sendgrid-methods.php


示例8: 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


示例9: testSendResponseWithSslOptionFalse

 public function testSendResponseWithSslOptionFalse()
 {
     $sendgrid = new SendGrid("foo", "bar", array("switch_off_ssl_verification" => true));
     $email = new SendGrid\Email();
     $email->setFrom('[email protected]')->setSubject('foobar subject')->setText('foobar text')->addTo('[email protected]')->addAttachment('./text');
     $response = $sendgrid->send($email);
     $this->assertEquals("Bad username / password", $response->errors[0]);
 }
开发者ID:enginethemes,项目名称:et_mailing,代码行数:8,代码来源:SendGrid.php


示例10: 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('[email protected]')->setSubject($subject)->setText($text)->setHtml($html);
    $sendgrid->send($email);
}
开发者ID:ssaamm,项目名称:schedule-ninja,代码行数:8,代码来源:handle_sendgrid.php


示例11: 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('[email protected]')->setSubject($title)->setText($body);
     $response = $sendgrid->send($email);
     return $response->getCode() == 200;
 }
开发者ID:piax93,项目名称:tripzor_server,代码行数:16,代码来源:MailSender.php


示例12: _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


示例13: 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


示例14: 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


示例15: 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


示例16: sendEmail

 protected function sendEmail($to, $subj, $text, $html = null)
 {
     $email = new \SendGrid\Email();
     $email->addCategory($subj);
     $email->addTo($to);
     $email->setFrom('[email protected]');
     $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


示例17: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     UserTestHelper::createBasicUser('billy');
     UserTestHelper::createBasicUser('jane');
     $someoneSuper = UserTestHelper::createBasicUser('someoneSuper');
     $group = Group::getByName('Super Administrators');
     $group->users->add($someoneSuper);
     $saved = $group->save();
     assert($saved);
     // Not Coding Standard
     $box = EmailBox::resolveAndGetByName(EmailBox::NOTIFICATIONS_NAME);
     SendGrid::register_autoloader();
     Smtpapi::register_autoloader();
     if (SendGridTestHelper::isSetSendGridAccountTestConfiguration()) {
         Yii::app()->sendGridEmailHelper->apiUsername = Yii::app()->params['emailTestAccounts']['sendGridGlobalSettings']['apiUsername'];
         Yii::app()->sendGridEmailHelper->apiPassword = Yii::app()->params['emailTestAccounts']['sendGridGlobalSettings']['apiPassword'];
         Yii::app()->sendGridEmailHelper->setApiSettings();
         Yii::app()->sendGridEmailHelper->init();
         static::$testEmailAddress = Yii::app()->params['emailTestAccounts']['testEmailAddress'];
     }
     // Delete item from jobQueue, that is created when new user is created
     Yii::app()->jobQueue->deleteAll();
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:25,代码来源:SendGridEmailHelperTest.php


示例18: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     self::$emailHelperSendEmailThroughTransport = Yii::app()->emailHelper->sendEmailThroughTransport;
     static::$userpsg = UserTestHelper::createBasicUser('userpsg');
     static::$usercstmsmtp = UserTestHelper::createBasicUser('usercstmsmtp');
     static::$basicuser = UserTestHelper::createBasicUser('basicuser');
     static::$bothSGandCstmUser = UserTestHelper::createBasicUser('bothSGandCstmUser');
     $someoneSuper = UserTestHelper::createBasicUser('someoneSuper');
     $group = Group::getByName('Super Administrators');
     $group->users->add($someoneSuper);
     $saved = $group->save();
     assert($saved);
     // Not Coding Standard
     $box = EmailBox::resolveAndGetByName(EmailBox::NOTIFICATIONS_NAME);
     if (EmailMessageTestHelper::isSetEmailAccountsTestConfiguration()) {
         EmailMessageTestHelper::createEmailAccountForMailerFactory(static::$usercstmsmtp);
         EmailMessageTestHelper::createEmailAccountForMailerFactory(static::$bothSGandCstmUser);
     }
     SendGrid::register_autoloader();
     Smtpapi::register_autoloader();
     if (SendGridTestHelper::isSetSendGridAccountTestConfiguration()) {
         SendGridTestHelper::createSendGridEmailAccount(static::$userpsg);
         SendGridTestHelper::createSendGridEmailAccount(static::$bothSGandCstmUser);
         Yii::app()->sendGridEmailHelper->apiUsername = Yii::app()->params['emailTestAccounts']['sendGridGlobalSettings']['apiUsername'];
         Yii::app()->sendGridEmailHelper->apiPassword = Yii::app()->params['emailTestAccounts']['sendGridGlobalSettings']['apiPassword'];
         Yii::app()->sendGridEmailHelper->setApiSettings();
         Yii::app()->sendGridEmailHelper->init();
     }
     // Delete item from jobQueue, that is created when new user is created
     Yii::app()->jobQueue->deleteAll();
 }
开发者ID:KulturedKitsch,项目名称:kulturedkitsch.info,代码行数:33,代码来源:ZurmoMailerFactoryTest.php


示例19: send

 /**
  * {@inheritdoc}
  */
 public function send(Swift_Mime_Message $message, &$failedRecipients = null)
 {
     $sendgrid = new \SendGrid($this->key);
     $email = new \SendGrid\Email();
     list($from, $from_name) = $this->getFromAddresses($message);
     $email->setFrom($from);
     $email->setFromName($from_name);
     $email->setSubject($message->getSubject());
     $email->setHtml($message->getBody());
     $this->setTo($email, $message);
     $this->setCc($email, $message);
     $this->setBcc($email, $message);
     $this->setText($email, $message);
     $this->setAttachment($email, $message);
     $sendgrid->send($email);
     $this->deleteTempAttachments();
 }
开发者ID:neonbug,项目名称:meexo-common,代码行数:20,代码来源:SendGridTransport.php


示例20: send

 public function send()
 {
     $options = array('turn_off_ssl_verification' => true);
     $sendgrid = new \SendGrid($this->username, $this->password, $options);
     $email = new \SendGrid\Email();
     $email->addTo($this->to)->setFrom($this->from)->setSubject($this->subject)->setFromName($this->fromName)->setHtml($this->conteudo)->setCc($this->from)->addFilter('templates', 'enabled', 1)->addFilter('templates', 'template_id', $this->template);
     try {
         $sendgrid->send($email);
         return array('enviado' => true, 'mensagem' => 'Enviado com sucesso');
     } catch (\SendGrid\Exception $e) {
         $string = '';
         foreach ($e->getErrors() as $er) {
             $string .= $e->getCode() . ' - ' . $er . '<br/>';
         }
         return array('enviado' => false, 'mensagem' => $string);
     }
 }
开发者ID:denners777,项目名称:phalcon_ecommerce,代码行数:17,代码来源:Mailer.php



注:本文中的SendGrid类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP SendPress_Admin类代码示例发布时间:2022-05-23
下一篇:
PHP SemanticScuttle_Service_Factory类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap