當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。