/** * Execute sending process in Email * @see extension/ezcomments/classes/ezcomNotificationManager#executeSending($subject, $body, $subscriber) */ public function executeSending($subject, $body, $subscriber) { $email = $subscriber->attribute('email'); $parameters = array(); $parameters['content_type'] = $this->emailContentType; $parameters['from'] = $this->emailFrom; $transport = eZNotificationTransport::instance('ezmail'); $result = $transport->send(array($email), $subject, $body, null, $parameters); if ($result === false) { throw new Exception('Send email error! Subscriber id:' . $subscriber->attribute('id')); } eZDebugSetting::writeNotice('extension-ezcomments', "An email has been sent to '{$email}' (subject: {$subject})", __METHOD__); }
function handle($event) { eZDebugSetting::writeDebug('kernel-notification', $event, "trying to handle event"); if ($event->attribute('event_type_string') == 'ezcurrenttime') { $date = $event->content(); $timestamp = $date->attribute('timestamp'); $addressArray = $this->fetchUsersForDigest($timestamp); $tpl = eZTemplate::factory(); $prevTplUsageStats = $tpl->setIsTemplatesUsageStatisticsEnabled(false); $transport = eZNotificationTransport::instance('ezmail'); foreach ($addressArray as $address) { $tpl->setVariable('date', $date); $tpl->setVariable('address', $address['address']); $result = $tpl->fetch('design:notification/handler/ezgeneraldigest/view/plain.tpl'); $subject = $tpl->variable('subject'); $parameters = array(); if ($tpl->hasVariable('content_type')) { $parameters['content_type'] = $tpl->variable('content_type'); } $transport->send($address, $subject, $result, null, $parameters); eZDebugSetting::writeDebug('kernel-notification', $result, "digest result"); } $collectionItemIDList = $tpl->variable('collection_item_id_list'); eZDebugSetting::writeDebug('kernel-notification', $collectionItemIDList, "handled items"); $tpl->setIsTemplatesUsageStatisticsEnabled($prevTplUsageStats); if (is_array($collectionItemIDList) && count($collectionItemIDList) > 0) { $ini = eZINI::instance('notification.ini'); $countElements = $ini->variable('RuleSettings', 'LimitDeleteElements'); if (!$countElements) { $countElements = 50; } $splited = array_chunk($collectionItemIDList, $countElements); foreach ($splited as $key => $value) { eZPersistentObject::removeObject(eZNotificationCollectionItem::definition(), array('id' => array($value, ''))); } } } return true; }
function sendMessage($event, $parameters) { $collections = eZNotificationCollection::fetchListForHandler(self::NOTIFICATION_HANDLER_ID, $event->attribute('id'), self::TRANSPORT); foreach ($collections as $collection) { $items = $collection->attribute('items_to_send'); $addressList = array(); foreach ($items as $item) { $addressList[] = $item->attribute('address'); $item->remove(); } $transport = eZNotificationTransport::instance('ezmail'); $transport->send($addressList, $collection->attribute('data_subject'), $collection->attribute('data_text'), null, $parameters); if ($collection->attribute('item_count') == 0) { $collection->remove(); } } }
function sendMessage($event, $parameters) { $collection = eZNotificationCollection::fetchForHandler(self::NOTIFICATION_HANDLER_ID, $event->attribute('id'), self::TRANSPORT); if (!$collection) { return; } $items = $collection->attribute('items_to_send'); if (!$items) { eZDebugSetting::writeDebug('kernel-notification', "No items to send now"); return; } $addressList = array(); foreach ($items as $item) { $addressList[] = $item->attribute('address'); $item->remove(); } $transport = eZNotificationTransport::instance('ezmail'); $transport->send($addressList, $collection->attribute('data_subject'), $collection->attribute('data_text'), null, $parameters); if ($collection->attribute('item_count') == 0) { $collection->remove(); } }
/** * send activation email to the user * @param ezcomContentObject $contentObject * @param ezcomSubscriber $subscriber * @param ezcomSubscription $subscription * @return true if mail sending succeeds * false if mail sending fails */ public static function sendActivationEmail($contentObject, $subscriber, $subscription) { $transport = eZNotificationTransport::instance('ezmail'); $email = $subscriber->attribute('email'); $tpl = eZTemplate::factory(); $tpl->setVariable('contentobject', $contentObject); $tpl->setVariable('subscriber', $subscriber); $tpl->setVariable('subscription', $subscription); $mailSubject = $tpl->fetch('design:comment/notification_activation_subject.tpl'); $mailBody = $tpl->fetch('design:comment/notification_activation_body.tpl'); $parameters = array(); $ezcommentsINI = eZINI::instance('ezcomments.ini'); $mailContentType = $ezcommentsINI->variable('NotificationSettings', 'ActivationMailContentType'); $parameters['from'] = $ezcommentsINI->variable('NotificationSettings', 'MailFrom'); $parameters['content_type'] = $mailContentType; $result = $transport->send(array($email), $mailSubject, $mailBody, null, $parameters); return $result; }