本文整理汇总了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']}!");
}
}
}
示例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);
}