/** * Loads a list of static routes for the specicifies parameters, returns an array of Tool\Email\Blacklist elements * * @return array */ public function load() { $addressData = $this->db->fetchCol("SELECT address FROM email_blacklist" . $this->getCondition() . $this->getOrder() . $this->getOffsetLimit(), $this->model->getConditionVariables()); $addresses = array(); foreach ($addressData as $data) { if ($address = Model\Tool\Email\Blacklist::getByAddress($data)) { $addresses[] = $address; } } $this->model->setItems($addresses); return $addresses; }
public function blacklistAction() { if (!$this->getUser()->isAllowed("emails")) { throw new \Exception("Permission denied, user needs 'emails' permission."); } if ($this->getParam("data")) { $data = \Zend_Json::decode($this->getParam("data")); if (is_array($data)) { foreach ($data as &$value) { $value = trim($value); } } if ($this->getParam("xaction") == "destroy") { $address = Tool\Email\Blacklist::getByAddress($data); $address->delete(); $this->_helper->json(array("success" => true, "data" => array())); } elseif ($this->getParam("xaction") == "update") { $address = Tool\Email\Blacklist::getByAddress($data["address"]); $address->setValues($data); $address->save(); $this->_helper->json(array("data" => $address, "success" => true)); } elseif ($this->getParam("xaction") == "create") { unset($data["id"]); $address = new Tool\Email\Blacklist(); $address->setValues($data); $address->save(); $this->_helper->json(array("data" => $address, "success" => true)); } } else { // get list of routes $list = new Tool\Email\Blacklist\Listing(); $list->setLimit($this->getParam("limit")); $list->setOffset($this->getParam("start")); $sortingSettings = \Pimcore\Admin\Helper\QueryParams::extractSortingSettings($this->getAllParams()); if ($sortingSettings['orderKey']) { $orderKey = $sortingSettings['orderKey']; } if ($sortingSettings['order']) { $order = $sortingSettings['order']; } if ($this->getParam("filter")) { $list->setCondition("`address` LIKE " . $list->quote("%" . $this->getParam("filter") . "%")); } $data = $list->load(); $this->_helper->json(array("success" => true, "data" => $data, "total" => $list->getTotalCount())); } $this->_helper->json(false); }
/** * Sends this email using the given transport or with the settings from "Settings" -> "System" -> "Email Settings" * * IMPORTANT: If the debug mode is enabled in "Settings" -> "System" -> "Debug" all emails will be sent to the * debug email addresses that are given in "Settings" -> "System" -> "Email Settings" -> "Debug email addresses" * * set DefaultTransport or the internal mail function if no * default transport had been set. * * @param \Zend_Mail_Transport_Abstract $transport * @return \Pimcore\Mail Provides fluent interface */ public function send($transport = null) { // filter email addresses $blockedAddresses = array(); foreach ($this->getRecipients() as $recipient) { if (Model\Tool\Email\Blacklist::getByAddress($recipient)) { $blockedAddresses[] = $recipient; } } if (!empty($blockedAddresses)) { foreach ($blockedAddresses as $blockedAddress) { foreach (["To", "Cc", "Bcc"] as $type) { $tmp = $this->_headers[$type]; foreach ($tmp as $key => &$value) { if (strpos($value, $blockedAddress) !== false) { unset($this->_headers[$type][$key]); unset($this->_recipients[$value]); } } } } } $this->setSubject($this->getSubjectRendered()); $bodyHtmlRendered = $this->getBodyHtmlRendered(); if ($bodyHtmlRendered) { $this->setBodyHtml($bodyHtmlRendered); } $bodyTextRendered = $this->getBodyTextRendered(); if ($bodyTextRendered) { $this->setBodyText($bodyTextRendered); } if ($this->ignoreDebugMode == false) { $this->checkDebugMode(); } $result = parent::send($transport); if ($this->loggingIsEnabled()) { try { MailHelper::logEmail($this); } catch (\Exception $e) { \Logger::emerg("Couldn't log Email"); } } return $result; }