本文整理汇总了PHP中Illuminate\Contracts\Mail\Mailer::failures方法的典型用法代码示例。如果您正苦于以下问题:PHP Mailer::failures方法的具体用法?PHP Mailer::failures怎么用?PHP Mailer::failures使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Contracts\Mail\Mailer
的用法示例。
在下文中一共展示了Mailer::failures方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* Handler
*
* @param \Illuminate\Contracts\Mail\Mailer $mailer
* @param \Illuminate\Contracts\View\Factory $view
* @param \Illuminate\Contracts\Validation\Factory $validator
* @throws \Exception
* @return void
*/
public function handle(Mailer $mailer, Factory $view, Validator $validator)
{
$queue = $this->messageQueue;
$queue->status = 'in_processes';
$queue->save();
$queue->load('event', 'event.template');
$parameters = array_merge_recursive($queue->event->template->parameters, $queue->event->parameters, $queue->parameters);
$messageParameters = array_dot($this->getMessageParameters($validator, $parameters['message']));
$renderView = $queue->event->template->getRender($parameters['view']);
$mailer->send('message-sender::providers.plain', ['content' => $renderView], function ($message) use($parameters, $messageParameters) {
$message->from($messageParameters['from.address'], $messageParameters['from.name']);
$message->to($messageParameters['to.address'], $messageParameters['from.name']);
$message->subject($parameters['provider']['subject']);
if (isset($parameters['provider']['headers'])) {
$mailHeaders = $message->getSwiftMessage()->getHeaders();
foreach ($parameters['provider']['headers'] as $header) {
$mailHeaders->addTextHeader($header['name'], $header['value']);
}
}
});
if (count($mailer->failures()) > 0) {
throw new \Exception('Mail send failed.');
} else {
$queue->status = 'sent';
$queue->save();
}
}
示例2: failures
/**
* Get the array of failed recipients.
*
* @return array
*/
public function failures()
{
return $this->mailer->failures();
}