Admin_EmailController::resendEmailAction PHP Method

resendEmailAction() public method

Resends the email to the recipients
public resendEmailAction ( )
    public function resendEmailAction()
    {
        if (!$this->getUser()->isAllowed("emails")) {
            throw new \Exception("Permission denied, user needs 'emails' permission.");
        }
        $success = false;
        $emailLog = Tool\Email\Log::getById($this->getParam('id'));
        if ($emailLog instanceof Tool\Email\Log) {
            $mail = new Mail();
            $mail->preventDebugInformationAppending();
            $mail->disableLogging();
            $mail->setIgnoreDebugMode(true);
            if ($html = $emailLog->getHtmlLog()) {
                $mail->setBodyHtml($html);
            }
            if ($text = $emailLog->getTextLog()) {
                $mail->setBodyText($text);
            }
            $mail->setFrom($emailLog->getFrom());
            foreach ($emailLog->getToAsArray() as $entry) {
                $mail->addTo($entry['email'], $entry['name']);
            }
            foreach ($emailLog->getCcAsArray() as $entry) {
                $mail->addCc($entry['email'], $entry['name']);
            }
            foreach ($emailLog->getBccAsArray() as $entry) {
                $mail->addBcc($entry['email']);
            }
            $mail->setSubject($emailLog->getSubject());
            $mail->send();
            $success = true;
        }
        $this->_helper->json(["success" => $success]);
    }