/** * ADMIN STUFF * * @author Philipp Staender */ function send() { if (!$this->isAjax()) { exit("<h2>send() only via ajax-request</h2>Security issue..."); } $id = (int) Director::urlParam("ID"); $count = (int) Director::urlParam("OtherID"); if (!($id > 0 && $count > 0)) { exit('<h2>Syntax</h2>' . $this->URL() . '/send/$newsletter_campaign_id/$numbers_of_sendings_per_request/'); } if ($camp = DataObject::get_by_id("NewsletterCampaign", $id)) { $newsletterCategory = DataObject::get_by_id("NewsletterCategory", $camp->NewsletterCategoryID); if ($recievers = DataObject::get("NewsletterReciever", "NewsletterID = {$id} AND Send = 0")) { //send emails $i = 0; //to each reciever foreach ($recievers as $r) { if ($i < $count) { //send only, if sended items of this session are smaller than given in the url $content = NewsletterCampaign::getRenderedNewsletterContent($camp, $r); if (DataObject::get("NewsletterBlacklist", "Email LIKE '" . $r->Email . "' AND NewsletterCategoryID = " . $camp->NewsletterCategoryID)) { $r->Send = 2; $r->write(); //do not send } else { $email = new Email($camp->sendFromEmail(), $r->Email, $camp->Title, $content); if (NewsletterHolder::$emailBodyTemplate) { $email->setTemplate(NewsletterHolder::$emailBodyTemplate); } if ($email->send()) { $r->Send = 1; $r->write(); $i++; } } } } exit($i . ""); } } return array(); }
<?php //do some config stuff here, if you like //otherwise delete / comment the following lines NewsletterHolder::$newsletterEmail = "admin@127.0.0.1"; //use a custom body template for email, otherwise its used an default Sapphire template NewsletterHolder::$emailBodyTemplate = "EmailTemplate"; NewsletterHolder::$newsletterTemplate = "NewsletterTemplate"; NewsletterHolder::$signupRequiredFields = array("Email"); //sendings per click, keep it between 5 - 20, if ou have a slow webserver, try below 5 NewsletterHolder::$sendingsPerClick = 10; //transform pictures + links to absolue urls (better for newsletters) NewsletterCampaign::$makeRelativeToAbsoluteURLS = true;
function send_to($data) { $email = $_REQUEST['email']; if (!NewsletterCampaign::isValidEmail($email)) { echo _t("Newsletter.Admin.NoValidEmail", "Please choose a valid eMail address..."); exit; } $this->dataRecord->sendTo($email); echo _t("Newsletter.Admin.SendTestmailTo", "Send testmail to") . " '" . $email . "'..."; exit; }