protected function _renderMails($config)
    {
        $mails = array();
        $config = new AnConfig($config);
        $settings = $config->settings;
        $people = $config->people;
        $notification = $config->notification;

        foreach ($people as  $person) {

            $setting = $settings->{$person->id};

            if (! $ret = $notification->shouldNotify($person, $setting)) {
                $notification->removeSubscribers($person);
                continue;
            }

            $person->addNotification($notification);

            if ($ret !== ComNotificationsDomainDelegateSettingInterface::NOTIFY_WITH_EMAIL) {
                continue;
            }

            //since each owner revieces the mail, they are in fact the viewer
            //so we need to set the as viewer while processing the notification
            AnService::set('com:people.viewer', $person);

            $notification->owner = $person;
            $data = new AnConfig($this->_parser->parse($notification));

            $data->append(array(
                'email_subject' => $data->title,
                'email_title' => pick($data->email_subject, $data->title),
                'email_body' => $data->body,
                'notification' => $notification
            ));

            if ($notification->target && !$notification->target->eql($person)) {
                $data->commands->insert('notification_setting', array('actor' => $notification->target));
            }

            $body = $this->renderMail(array(
                        'template' => 'notification',
                        'layout' => false,
                        'data' => array(
                            'person' => $person,
                            'commands' => $data->commands,
                            'subject' => $notification->subject,
                            'title' => $data->email_title,
                            'body' => $data->email_body
                        )
                    ));

            if ($person->email != '' && filter_var($person->email, FILTER_VALIDATE_EMAIL)) {
                $mails[] = array(
                      'subject' => $data->email_subject,
                      'body' => $body,
                      'to' => $person->email
                );
            }
        }

        return $mails;
    }