当前位置: 首页>>代码示例>>PHP>>正文


PHP Email::set_mailer方法代码示例

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


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

示例1: run

 function run($request)
 {
     //IMPORTANT!
     Config::inst()->update("Email", "send_all_emails_to", "no-one@localhost");
     Email::set_mailer(new EcommerceTaskTryToFinaliseOrders_Mailer());
     $orderStatusLogClassName = "OrderStatusLog";
     $submittedOrderStatusLogClassName = EcommerceConfig::get("OrderStatusLog", "order_status_log_class_used_for_submitting_order");
     if ($submittedOrderStatusLogClassName) {
         $sampleSubmittedStatusLog = $submittedOrderStatusLogClassName::get()->First();
         if ($sampleSubmittedStatusLog) {
             $lastOrderStep = OrderStep::get()->sort("Sort", "DESC")->First();
             if ($lastOrderStep) {
                 $joinSQL = "INNER JOIN \"{$orderStatusLogClassName}\" ON \"{$orderStatusLogClassName}\".\"OrderID\" = \"Order\".\"ID\"";
                 $whereSQL = "WHERE \"StatusID\" <> " . $lastOrderStep->ID . " AND \"{$orderStatusLogClassName}\".ClassName = '{$submittedOrderStatusLogClassName}'";
                 $count = DB::query("\r\n\t\t\t\t\t\tSELECT COUNT (\"Order\".\"ID\")\r\n\t\t\t\t\t\tFROM \"Order\"\r\n\t\t\t\t\t\t{$joinSQL}\r\n\t\t\t\t\t\t{$whereSQL}\r\n\t\t\t\t\t")->value();
                 $do = DB::query("\r\n\t\t\t\t\t\tUPDATE \"Order\"\r\n\t\t\t\t\t\t{$joinSQL}\r\n\t\t\t\t\t\tSET \"Order\".\"StatusID\" = " . $lastOrderStep->ID . "\r\n\t\t\t\t\t\t{$whereSQL}\r\n\t\t\t\t\t");
                 if ($count) {
                     DB::alteration_message("NOTE: {$count} records were updated.", "created");
                 } else {
                     DB::alteration_message("No records were updated.");
                 }
             } else {
                 DB::alteration_message("Could not find the last order step.", "deleted");
             }
         } else {
             DB::alteration_message("Could not find any submitted order logs.", "deleted");
         }
     } else {
         DB::alteration_message("Could not find a class name for submitted orders.", "deleted");
     }
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce,代码行数:31,代码来源:EcommerceTaskArchiveAllSubmittedOrders.php

示例2: preRequest

 public function preRequest(SS_HTTPRequest $request, Session $session, DataModel $model)
 {
     if (!$this->testSessionEnvironment->isRunningTests()) {
         return;
     }
     $testState = $this->testSessionEnvironment->getState();
     // Date and time
     if (isset($testState->datetime)) {
         SS_Datetime::set_mock_now($testState->datetime);
     }
     // Register mailer
     if (isset($testState->mailer)) {
         $mailer = $testState->mailer;
         Email::set_mailer(new $mailer());
         Config::inst()->update("Email", "send_all_emails_to", null);
     }
     // Allows inclusion of a PHP file, usually with procedural commands
     // to set up required test state. The file can be generated
     // through {@link TestSessionStubCodeWriter}, and the session state
     // set through {@link TestSessionController->set()} and the
     // 'testsession.stubfile' state parameter.
     if (isset($testState->stubfile)) {
         $file = $testState->stubfile;
         if (!Director::isLive() && $file && file_exists($file)) {
             // Connect to the database so the included code can interact with it
             global $databaseConfig;
             if ($databaseConfig) {
                 DB::connect($databaseConfig);
             }
             include_once $file;
         }
     }
 }
开发者ID:jeffreyguo,项目名称:silverstripe-testsession,代码行数:33,代码来源:TestSessionRequestFilter.php

示例3: tearDown

 public function tearDown()
 {
     $_SERVER['HTTP_HOST'] = $this->oldhost;
     Config::unnest();
     Email::set_mailer(new Mailer());
     parent::tearDown();
 }
开发者ID:helpfulrobot,项目名称:silverstripe-comment-notifications,代码行数:7,代码来源:CommentNotifierTest.php

示例4: before

 /**
  * @BeforeScenario
  */
 public function before(ScenarioEvent $event)
 {
     // Also set through the 'supportbehat' extension
     // to ensure its available both in CLI execution and the tested browser session
     $this->mailer = new \SilverStripe\BehatExtension\Utility\TestMailer();
     \Email::set_mailer($this->mailer);
     \Config::inst()->update("Email", "send_all_emails_to", null);
 }
开发者ID:helpfulrobot,项目名称:silverstripe-behat-extension,代码行数:11,代码来源:EmailContext.php

示例5: testSetup

 public function testSetup()
 {
     Object::useCustomClass('Email', 'SMTPEmail');
     Email::set_mailer(new SmtpMailer());
     SMTPEmail::set_mailer(new SmtpMailer());
     $mailer = Email::mailer();
     $this->assertEquals('SmtpMailer', get_class($mailer));
     $mailer = SMTPEmail::mailer();
     $this->assertEquals('SmtpMailer', get_class($mailer));
 }
开发者ID:helpfulrobot,项目名称:azt3k-abc-silverstripe-mailer,代码行数:10,代码来源:SMTPMailerTest.php

示例6: setAsMailer

 /**
  * Helper method to initialize the mailer
  *
  * @return SparkPostMailer
  */
 public static function setAsMailer()
 {
     $mailer = self::getInstance();
     // On SilverStripe 3.1, injector is not used
     $version = self::getFrameworkVersion();
     if (version_compare($version, '3.2.0', '<')) {
         Email::set_mailer($mailer);
     }
     Injector::inst()->registerService($mailer, 'Mailer');
     return $mailer;
 }
开发者ID:lekoala,项目名称:silverstripe-sparkpost,代码行数:16,代码来源:SparkPostMailer.php

示例7: setAsMailer

 /**
  * Helper method to initialize the mailer
  *
  * @param string $apiKey
  * @throws Exception
  */
 public static function setAsMailer($apiKey = null)
 {
     if ($apiKey === null) {
         if (defined('MANDRILL_API_KEY')) {
             $apiKey = MANDRILL_API_KEY;
         }
     }
     if (empty($apiKey)) {
         throw new Exception('Api key is empty');
     }
     $mandrillMailer = new MandrillMailer($apiKey);
     Email::set_mailer($mandrillMailer);
 }
开发者ID:philbenoit,项目名称:silverstripe-mandrill,代码行数:19,代码来源:MandrillMailer.php

示例8: setAsMailer

 /**
  * Helper method to initialize the mailer
  *
  * @param string $apiKey
  * @throws Exception
  */
 public static function setAsMailer()
 {
     $mandrillMailer = new MandrillMailer();
     Email::set_mailer($mandrillMailer);
     if (defined('MANDRILL_SENDING_DISABLED') && MANDRILL_SENDING_DISABLED) {
         self::setSendingDisabled();
     }
     if (defined('MANDRILL_ENABLE_LOGGING') && MANDRILL_ENABLE_LOGGING) {
         self::setEnableLogging();
     }
     // Use custom classes
     Object::useCustomClass('Member_ChangePasswordEmail', 'Mandrill_ChangePasswordEmail');
     Object::useCustomClass('Member_ForgotPasswordEmail', 'Mandrill_ForgotPasswordEmail');
 }
开发者ID:helpfulrobot,项目名称:lekoala-silverstripe-mandrill,代码行数:20,代码来源:MandrillMailer.php

示例9: testSendHTML

 public function testSendHTML()
 {
     // Set custom $project - used in email headers
     global $project;
     $oldProject = $project;
     $project = 'emailtest';
     Email::set_mailer(new EmailTest_Mailer());
     $email = new Email('from@example.com', 'to@example.com', 'Test send plain', 'Testing Email->sendPlain()', null, 'cc@example.com', 'bcc@example.com');
     $email->attachFile(__DIR__ . '/fixtures/attachment.txt', null, 'text/plain');
     $email->addCustomHeader('foo', 'bar');
     $sent = $email->send(123);
     // Restore old project name after sending
     $project = $oldProject;
     $this->assertEquals('to@example.com', $sent['to']);
     $this->assertEquals('from@example.com', $sent['from']);
     $this->assertEquals('Test send plain', $sent['subject']);
     $this->assertContains('Testing Email->sendPlain()', $sent['content']);
     $this->assertNull($sent['plaincontent']);
     $this->assertEquals(array(0 => array('contents' => 'Hello, I\'m a text document.', 'filename' => 'attachment.txt', 'mimetype' => 'text/plain')), $sent['files']);
     $this->assertEquals(array('foo' => 'bar', 'X-SilverStripeMessageID' => 'emailtest.123', 'X-SilverStripeSite' => 'emailtest', 'Cc' => 'cc@example.com', 'Bcc' => 'bcc@example.com'), $sent['customheaders']);
 }
开发者ID:congaaids,项目名称:silverstripe-framework,代码行数:21,代码来源:EmailTest.php

示例10: SmtpMailer

<?php

Object::useCustomClass('Email', 'SMTPEmail');
Email::set_mailer(new SmtpMailer());
SMTPEmail::set_mailer(new SmtpMailer());
开发者ID:helpfulrobot,项目名称:azt3k-abc-silverstripe-mailer,代码行数:5,代码来源:_config.php

示例11: run

 /**
  *@return Integer - number of carts destroyed
  **/
 public function run($request)
 {
     //IMPORTANT!
     if ($this->doNotSendEmails) {
         Config::inst()->update("Email", "send_all_emails_to", "no-one@localhost");
         Email::set_mailer(new EcommerceTaskTryToFinaliseOrders_Mailer());
     }
     $orderStatusLogClassName = "OrderStatusLog";
     $submittedOrderStatusLogClassName = EcommerceConfig::get("OrderStatusLog", "order_status_log_class_used_for_submitting_order");
     if ($submittedOrderStatusLogClassName) {
         $submittedStatusLog = $submittedOrderStatusLogClassName::get()->First();
         if ($submittedStatusLog) {
             $orderSteps = OrderStep::get()->sort("Sort", "DESC")->limit(1);
             $lastOrderStep = $orderSteps->First();
             if ($lastOrderStep) {
                 $joinSQL = "INNER JOIN \"\" ON ";
                 $whereSQL = "\"StatusID\" <> " . $lastOrderStep->ID . "";
                 $count = null;
                 if (isset($_GET["count"])) {
                     $count = intval($_GET["count"]);
                 }
                 if (!intval($count)) {
                     $count = 50;
                 }
                 $last = null;
                 if (isset($_GET["last"])) {
                     $last = intval($_GET["last"]);
                 }
                 if (!intval($last)) {
                     $last = intval(Session::get("EcommerceTaskTryToFinaliseOrders"));
                     if (!$last) {
                         $last = 0;
                     }
                 }
                 $orders = Order::get()->where($whereSQL)->sort("ID", "ASC")->innerJoin($orderStatusLogClassName, "\"{$orderStatusLogClassName}\".\"OrderID\" = \"Order\".\"ID\"")->limit($count, $last);
                 if ($orders->count()) {
                     DB::alteration_message("<h1>Moving {$count} Orders (starting from {$last})</h1>");
                     foreach ($orders as $order) {
                         $last++;
                         Session::set("EcommerceTaskTryToFinaliseOrders", $last);
                         $stepBefore = OrderStep::get()->byID($order->StatusID);
                         try {
                             $order->tryToFinaliseOrder();
                         } catch (Exception $e) {
                             DB::alteration_message($e, "deleted");
                         }
                         $stepAfter = OrderStep::get()->byID($order->StatusID);
                         if ($stepBefore) {
                             if ($stepBefore->ID == $stepAfter->ID) {
                                 DB::alteration_message("could not move Order " . $order->getTitle() . ", remains at <strong>" . $stepBefore->Name . "</strong>");
                             } else {
                                 DB::alteration_message("Moving Order #" . $order->getTitle() . " from <strong>" . $stepBefore->Name . "</strong> to <strong>" . $stepAfter->Name . "</strong>", "created");
                             }
                         } else {
                             DB::alteration_message("Moving Order " . $order->getTitle() . " from <strong>unknown step</strong> to <strong>" . $stepAfter->Name . "</strong>", "created");
                         }
                     }
                 } else {
                     Session::clear("EcommerceTaskTryToFinaliseOrders");
                     DB::alteration_message("<br /><br /><br /><br /><h1>COMPLETED!</h1>All orders have been moved.", "created");
                 }
             } else {
                 DB::alteration_message("NO last order step.", "deleted");
             }
         } else {
             DB::alteration_message("NO submitted order status log.", "deleted");
         }
     } else {
         DB::alteration_message("NO EcommerceConfig::get(\"OrderStatusLog\", \"order_status_log_class_used_for_submitting_order\")", "deleted");
     }
     if (Session::get("EcommerceTaskTryToFinaliseOrders")) {
         DB::alteration_message("WAIT: we are still moving more orders ... this page will automatically load the next lot in 5 seconds.", "deleted");
         echo "<script type=\"text/javascript\">window.setTimeout(function() {location.reload();}, 5000);</script>";
     }
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce,代码行数:78,代码来源:EcommerceTaskTryToFinaliseOrders.php

示例12: CustomMailer

<?php

/*
 * Uncomment lines below to configure username, password and/or "From" mail
 */
// define('SENDGRIDMAILER_USERNAME', '<username>');
// define('SENDGRIDMAILER_PASSWORD', '<password>');
// define('SENDGRIDMAILER_MAIL', 'Info Test <info@testmail.com>'); //
Email::set_mailer(new CustomMailer());
SS_Log::add_writer(new SS_LogFileWriter(BASE_PATH . '/info.log'), SS_Log::INFO);
开发者ID:tony13tv,项目名称:silverstripe-sendgrid-integration,代码行数:10,代码来源:_config.php

示例13: SendGridWebMailer

<?php

/**
 * Copyright 2015 Openstack Foundation
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 **/
if (defined("SENDGRID_REST_API")) {
    Email::set_mailer(new SendGridWebMailer());
}
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:17,代码来源:_config.php

示例14: PHPMailerMailer

<?php

if (class_exists('StyledHtmlEmail')) {
    $mailer = new PHPMailerMailer();
    Email::set_mailer($mailer);
}
开发者ID:helpfulrobot,项目名称:dnadesign-silverstripe-alertmanager,代码行数:6,代码来源:_config.php

示例15: LoggingMailer

<?php

/**
 *
 * PHP version 5
 *
 * LICENSE: This source file is subject to version 3.01 of the PHP license
 * that is available through the world-wide-web at the following URI:
 * http://www.php.net/license/3_01.txt.  If you did not receive a copy of
 * the PHP License and are unable to obtain it through the web, please
 * send a note to license@php.net so we can mail you a copy immediately.
 *
 * @package   LoggingMailer
 * @author     Nathaniel McHugh <nat@fishtrap.co.uk>
 */
Email::set_mailer(new LoggingMailer());
SS_Report::register('ReportAdmin', 'SentMailReport', -10);
开发者ID:natmchugh,项目名称:loggingmailer,代码行数:17,代码来源:_config.php


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