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


PHP CakeEmail::transportClass方法代码示例

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


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

示例1: run

 /**
  * Find a potential queue and if found, send each email one by one
  *
  * @return void
  */
 public function run()
 {
     // The consumer ID will be placed against all pending emails
     $consumerId = uniqid();
     // Inform the user of the consumer id before proceeding
     $this->_renderHeader();
     $this->out("   Consumer ID: {$consumerId}", 2);
     // Search for pending emails and apply the consumer id to them
     if (!$this->EmailQueue->updatePending($consumerId)) {
         return $this->out('   Found 0 items in queue, exiting ...', 2);
     }
     // Find all the emails which were assigned with the consumer id
     $pendingItems = $this->EmailQueue->pendingItems($consumerId);
     $this->out('   Found ' . count($pendingItems) . ' items in queue, dispatching:', 2);
     // Loop through each email one by one
     foreach ($pendingItems as $item) {
         // Inform the user which email is being processed currency
         $this->out('    ' . str_pad("# {$item['EmailQueue']['id']}", 7, ' ') . '  ' . str_pad($item['EmailQueue']['to'] . '  ', 40, '.'), false);
         // Use your preferred email config here
         $email = new CakeEmail('custom');
         // Attempt to send the serialized email using the above config, log the status
         if ($email->transportClass()->send(unserialize($item['EmailQueue']['serialized']))) {
             $status = 1;
             $this->out('  [<success> OK </success>]', 2);
         } else {
             $status = 2;
             $this->out('  [<warning> !! </warning>]', 2);
         }
         // Attempt to update the email queue record with the new status
         if (!$this->EmailQueue->saveItemStatus($item['EmailQueue']['id'], $status)) {
             throw new Exception("Saving queue item failed, orphan created for ID #{$item['EmailQueue']['id']}!");
         }
     }
 }
开发者ID:thedrumz,项目名称:music,代码行数:39,代码来源:EmailQueueShell.php

示例2: execute

 public function execute()
 {
     if (empty($this->args[0]) || empty($this->args[1])) {
         throw new MailqueueArgumentException('Rquired arguments "queue-name", "transport configuration name"');
     }
     $queueMailer = new CakeEmail($this->args[0]);
     $realMailer = new CakeEmail(empty($this->args[1]) ? null : $this->args[1]);
     $queueMailer->transportClass()->flush($realMailer);
 }
开发者ID:hakito,项目名称:cakephp-mailqueue-plugin,代码行数:9,代码来源:SendMailTask.php


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