public function bounceMailInboxListAction()
{
$this->checkPermission("emails");
$offset = $this->getParam("start") ? $this->getParam("start") + 1 : 1;
$limit = $this->getParam("limit") ? $this->getParam("limit") : 40;
$mail = $this->getBounceMailbox();
$mail->seek($offset);
$mails = [];
$count = 0;
while ($mail->valid()) {
$count++;
$message = $mail->current();
$mailData = ["subject" => iconv(mb_detect_encoding($message->subject), "UTF-8", $message->subject), "to" => $message->to, "from" => $message->from, "id" => (int) $mail->key()];
$date = new \DateTime();
$date->setTimestamp($message->date);
$mailData["date"] = $date->format("Y-m-d");
$mails[] = $mailData;
if ($count >= $limit) {
break;
}
$mail->next();
}
$this->_helper->json(["data" => $mails, "success" => true, "total" => $mail->countMessages()]);
}