NotifySend.php
[Pman.Core] / NotifySend.php
1 <?php
2 require_once 'Pman.php';
3
4 /**
5  * notification script sender - designed to be run by the Notify script - with many children running
6  * in parallel.
7  *
8  * called with an id of a core_notify element
9  *
10  * uses core_notify - to find an event to object and person.
11  *
12  * uses Events table to log failures
13  * 
14  * 
15  * calls $object->toEmail($person,$last_send, $notify) to generate an email struct with
16  *  array (
17  *      headers =>
18  *      recipients =>
19  *      body =>
20  *  )
21  *
22  *
23  * Note uses configuration
24  *
25  * Pman_Core_NotifySend[host] = 'localhost' << to override direct sending..
26  * Mail[helo] << helo host name
27  * Mail[socket_options] << any socket option.
28  */
29 class Pman_Core_NotifySend_Exception_Success extends Exception {}
30 class Pman_Core_NotifySend_Exception_Fail extends Exception {}
31
32
33 class Pman_Core_NotifySend extends Pman
34 {
35     static $cli_desc = "Send out single notification email (usually called from  Core/Notify)";
36     
37     static $cli_opts = array(
38         'debug' => array(
39             'desc' => 'Turn on debugging (see DataObjects debugLevel )',
40             'default' => 0,
41             'short' => 'v',
42             'min' => 0,
43             'max' => 0,
44             
45         ),
46         'DB_DataObject-debug' => array(
47             'desc' => 'Turn on debugging (see DataObjects debugLevel )',
48             'default' => 0,
49             'short' => 'd',
50             'min' => 1,
51             'max' => 1,
52             
53         ),
54         'force' => array(
55             'desc' => 'Force redelivery, even if it has been sent before or not queued...',
56             'default' => 0,
57             'short' => 'f',
58             'min' => 0,
59             'max' => 0,
60         ),
61         'send-to' => array(
62             'desc' => 'Send the message to this address, rather than the one listed.',
63             'default' => '',
64             'short' => 't',
65             'min' => 0,
66             'max' => 1,
67         )
68         
69         
70         
71     );
72     var $table = 'core_notify';
73     var $error_handler = 'die';
74     var $poolname = 'core';
75     var $server; // core_notify_server
76     
77     function getAuth()
78     {
79         $ff = HTML_FlexyFramework::get();
80         if (!$ff->cli) {
81             $this->errorHandler("access denied");
82         }
83         //HTML_FlexyFramework::ensureSingle(__FILE__, $this);
84         return true;
85         
86     }
87    
88     function get($id,$opts=array())
89     {
90
91         //print_r($opts);
92         if (!empty($opts['DB_DataObject-debug'])) {
93             DB_DataObject::debugLevel($opts['DB_DataObject-debug']);
94         }
95         
96         //DB_DataObject::debugLevel(1);
97         //date_default_timezone_set('UTC');
98         // phpinfo();exit;
99         $force = empty($opts['force']) ? 0 : 1;
100         
101         $w = DB_DataObject::factory($this->table);
102
103         if (!$w->get($id)) {
104             $this->errorHandler("invalid id\n");
105         }
106
107         if (!$force && !empty($w->sent) && strtotime($w->act_when) < strtotime($w->sent)) {
108              
109             $this->errorHandler("already sent - repeat to early\n");
110         }
111         
112         $this->server = DB_DataObject::Factory('core_notify_server')->getCurrent($this);
113
114         
115         if (!empty($opts['debug'])) {
116             print_r($w);
117             $ff = HTML_FlexyFramework::get();
118             if (!isset($ff->Core_Mailer)) {
119                 $ff->Core_Mailer = array();
120             }
121             HTML_FlexyFramework::get()->Core_Mailer['debug'] = true;
122         }
123         
124         $sent = (empty($w->sent) || preg_match('/^0000/', $w->sent)) ? false : true;
125         
126         if (!$force && (!empty($w->msgid) || $sent)) {
127             $ww = clone($w);
128             if (!$sent) {   // fix sent.
129                 $w->sent = $w->sent == '0000-00-00 00:00:00' ? $w->sqlValue('NOW()') :$w->sent; // do not update if sent.....
130                 $w->update($ww);
131             }    
132             $this->errorHandler("message has been sent already.\n");
133         }
134         
135         $o = $w->object();
136         
137         if ($o === false)  {
138              
139             $ev = $this->addEvent('NOTIFY', $w,   "Notification event cleared (underlying object does not exist)" );
140             $w->flagDone($ev, '');
141             $this->errorHandler(date('Y-m-d h:i:s ') . $ev->remarks);
142         }
143      
144         
145         
146         $p = $w->person();
147         
148         if (isset($p->active) && empty($p->active)) {
149             $ev = $this->addEvent('NOTIFY', $w, "Notification event cleared (not user not active any more)" );;
150              $w->flagDone($ev, '');
151             $this->errorHandler(date('Y-m-d h:i:s ') . $ev->remarks);
152         }
153         // has it failed mutliple times..
154         
155         if (!empty($w->field) && isset($p->{$w->field .'_fails'}) && $p->{$w->field .'_fails'} > 9) {
156             $ev = $this->addEvent('NOTIFY', $w, "Notification event cleared (user has to many failures)" );;
157             $w->flagDone($ev, '');
158             $this->errorHandler(date('Y-m-d h:i:s ') . $ev->remarks);
159         }
160         
161         // let's work out the last notification sent to this user..
162         $l = DB_DataObject::factory($this->table);
163         
164         $lar = array(
165                 'ontable' => $w->ontable,
166                 'onid' => $w->onid,
167         );
168         // only newer version of the database us this..
169         if (isset($w->person_table)) {
170             $personid_col = strtolower($w->person_table).'_id';
171             if (isset($w->{$personid_col})) {
172                 $lar[$personid_col] = $w->{$personid_col};
173             }
174         }
175         
176         
177         $l->setFrom( $lar );       
178         $l->whereAdd('id != '. $w->id);
179         $l->orderBy('sent DESC');
180         $l->limit(1);
181         $ar = $l->fetchAll('sent');
182         $last = empty($ar) ? date('Y-m-d H:i:s', 0) : $ar[0];
183         
184         // find last event..
185         $ev = DB_DataObject::factory('Events');
186         $ev->on_id = $w->id;                           // int(11)
187         $ev->on_table = $this->table;
188         $ev->limit(1);
189         $ev->orderBy('event_when DESC');
190         $ar = $ev->fetchAll('event_when');
191         $last_event = empty($ar) ? 0 : $ar[0];
192         $next_try_min = 5;
193         if ($last_event) {
194             $next_try_min = floor((time() - strtotime($last_event)) / 60) * 2;
195         }
196         $next_try = $next_try_min . ' MINUTES';
197          
198         // this may modify $p->email. (it will not update it though)
199         $email =  $this->makeEmail($o, $p, $last, $w, $force);
200         
201         if ($email === true)  {
202             $ev = $this->addEvent('NOTIFY', $w, "Notification event cleared (not required any more) - toEmail=true" );;
203             $w->flagDone($ev, '');
204             $this->errorHandler(date('Y-m-d h:i:s ') . $ev->remarks);
205         }
206         if (is_a($email, 'PEAR_Error')) {
207             $email =array(
208                 'error' => $email->toString()
209             );
210         }
211         
212         if (empty($p) && !empty($email['recipients'])) {
213             // make a fake person..
214             $p = (object) array(
215                 'email' => $email['recipients']
216             );
217         }
218          
219         if ($email === false || isset($email['error']) || empty($p)) {
220             // object returned 'false' - it does not know how to send it..
221             $ev = $this->addEvent('NOTIFYFAIL', $w, isset($email['error'])  ? $email['error'] : "INTERNAL ERROR  - We can not handle " . $w->ontable); 
222             $w->flagDone($ev, '');
223             $this->errorHandler(date('Y-m-d h:i:s ') . $ev->remarks);
224         }
225         
226          
227         
228         if (isset($email['later'])) {
229             
230             if (false == $this->server->updateNotifyToNextServer($w, $email['later'])) {
231                 // we could not find another server - we can try again.
232                 $pp = clone($w);
233                 $w->act_when = $email['later'];
234                 $w->update($pp);
235             }
236  
237             $this->errorHandler(date('Y-m-d h:i:s ') . " Delivery postponed by email creator to {$email['later']}");
238         }
239         
240          
241         if (empty($email['headers']['Message-Id'])) {
242             $HOST = gethostname();
243             $email['headers']['Message-Id'] = "<{$this->table}-{$id}@{$HOST}>";
244             
245         }
246         
247         
248             
249         
250         //$p->email = 'alan@akbkhome.com'; //for testing..
251         //print_r($email);exit;
252         // should we fetch the watch that caused it.. - which should contain the method to call..
253         // --send-to=test@xxx.com
254        
255         if (!empty($email['send-to'])) {
256             $p->email = $email['send-to'];
257         }
258          if (!empty($opts['send-to'])) {
259             $p->email = $opts['send-to'];
260         }
261         
262             // since some of them have spaces?!?!
263         $p->email = trim($p->email);
264       
265         // if to_email has not been set!?
266         if (empty($w->to_email) && $w->to_email != $p->email) {
267             $ww = clone($w);
268             $ww->to_email = $p->email;
269             $ww->update($w);
270             $w = clone($ww);
271         }
272       
273         
274         require_once 'Validate.php';
275         if (!Validate::email($p->email, true)) {
276             $ev = $this->addEvent('NOTIFYFAIL', $w, "INVALID ADDRESS: " . $p->email);
277             $w->flagDone($ev, '');
278             $this->errorHandler(date('Y-m-d h:i:s ') . "INVALID ADDRESS: " . $p->email. "\n");
279             
280         }
281         
282         
283         $ff = HTML_FlexyFramework::get();
284         
285         $explode_email = explode('@', $p->email);
286         $dom = array_pop($explode_email);
287         
288         $mxs = $this->mxs($dom);
289         $ww = clone($w);
290
291         // we might fail doing this...
292         // need to handle temporary failure..
293        
294         
295           // we try for 2 days..
296         $retry = 15;
297         if (strtotime($w->act_start) <  strtotime('NOW - 1 HOUR')) {
298             // older that 1 hour.
299             $retry = 60;
300         }
301         
302         if (strtotime($w->act_start) <  strtotime('NOW - 1 DAY')) {
303             // older that 1 day.
304             $retry = 120;
305         }
306         if (strtotime($w->act_start) <  strtotime('NOW - 2 DAY')) {
307             // older that 1 day.
308             $retry = 240;
309         }
310         
311         if (empty($mxs)) {
312             // only retry for 1 day if the MX issue..
313             if ($retry < 240) {
314                 $this->addEvent('NOTIFY', $w, 'MX LOOKUP FAILED ' . $dom );
315                 $w->flagLater(date('Y-m-d H:i:s', strtotime('NOW + ' . $retry . ' MINUTES')));
316                 $this->errorHandler(date('Y-m-d h:i:s') . $ev->remarks);
317             }
318             
319             $ev = $this->addEvent('NOTIFYFAIL', $w, "BAD ADDRESS - BAD DOMAIN - ". $p->email );
320             $w->flagDone($ev, '');
321             $this->errorHandler(date('Y-m-d h:i:s') . $ev->remarks);
322             
323             
324         }
325         
326         
327         
328         
329         if (!$force && strtotime($w->act_start) <  strtotime('NOW - 3 DAY')) {
330             $ev = $this->addEvent('NOTIFYFAIL', $w, "BAD ADDRESS - GIVE UP - ". $p->email );
331             $w->flagDone($ev, '');
332             $this->errorHandler(date('Y-m-d h:i:s') . $ev->remarks);
333         }
334         
335         
336         //$this->addEvent('NOTIFY', $w, 'GREYLISTED ' . $p->email . ' ' . $res->toString());
337         // we can only update act_when if it has not been sent already (only happens when running in force mode..)
338         // set act when if it's empty...
339         $w->act_when =  (!$w->act_when || $w->act_when == '0000-00-00 00:00:00') ? date('Y-m-d H:i:s', strtotime('NOW + ' . $retry . ' MINUTES')) : $w->act_when;
340         
341         $w->update($ww);
342         
343         $ww = clone($w);   
344         
345         $fail = false;
346         require_once 'Mail.php';
347         
348         $core_domain = DB_DataObject::factory('core_domain')->loadOrCreate($dom);
349         
350         $this->server->initHelo();
351         
352         if (!isset($ff->Mail['helo'])) {
353             $this->errorHandler("config Mail[helo] is not set");
354         }
355         
356         
357                         
358         foreach($mxs as $mx) {
359             
360            
361             $this->debug_str = '';
362             $this->debug("Trying SMTP: $mx / HELO {$ff->Mail['helo']}");
363             $mailer = Mail::factory('smtp', array(
364                     'host'    => $mx ,
365                     'localhost' => $ff->Mail['helo'],
366                     'timeout' => 15,
367                     'socket_options' =>  isset($ff->Mail['socket_options']) ? $ff->Mail['socket_options'] : null,
368                     //'debug' => isset($opts['debug']) ?  1 : 0,
369                     'debug' => 1,
370                     'debug_handler' => array($this, 'debugHandler')
371             ));
372             
373             // if the host is the mail host + it's authenticated add auth details
374             // this normally will happen if you sent  Pman_Core_NotifySend['host']
375              
376             
377             if (isset($ff->Mail['host']) && $ff->Mail['host'] == $mx && !empty($ff->Mail['auth'] )) {
378                 
379                 $mailer->auth = true;
380                 $mailer->username = $ff->Mail['username'];
381                 $mailer->password = $ff->Mail['password'];        
382             }
383             
384             if(!empty($ff->Core_Notify) && !empty($ff->Core_Notify['routes'])){
385                 
386                 // we might want to regex 'office365 as a mx host 
387                 foreach ($ff->Core_Notify['routes'] as $server => $settings){
388                     if(!in_array($dom, $settings['domains'])){
389                         continue;
390                     }
391                     
392                     // what's the minimum timespan.. - if we have 60/hour.. that's 1 every minute.
393                     // if it's newer that '1' minute...
394                     // then shunt it..
395                     
396                     $settings['rate'] = isset( $settings['rate']) ?  $settings['rate']  : 360;
397                     
398                     $seconds = floor((60 * 60) / $settings['rate']);
399                     
400                     $core_notify = DB_DataObject::factory($this->table);
401                     $core_notify->domain_id = $core_domain->id;
402                     $core_notify->server_id = $this->server->id;
403                     $core_notify->whereAdd("
404                         sent >= NOW() - INTERVAL $seconds SECOND
405                     ");
406                     
407                     if($core_notify->count()){
408                         $this->server->updateNotifyToNextServer( $w , date("Y-m-d H:i:s", time() + $seconds), true);
409                         $this->errorHandler(date('Y-m-d h:i:s ') . " Too many emails sent by {$dom} - requeing");
410                     }
411                      
412                     
413                     
414                     $mailer->host = $server;
415                     $mailer->auth = isset($settings['auth']) ? $settings['auth'] : true;
416                     $mailer->username = $settings['username'];
417                     $mailer->password = $settings['password'];
418                     if (isset($settings['port'])) {
419                         $mailer->port = $settings['port'];
420                     }
421                     if (isset($settings['socket_options'])) {
422                         $mailer->socket_options = $settings['socket_options'];
423                         
424                     }
425                     
426                     
427                     break;
428                 }
429                 
430             }
431         
432             
433             $res = $mailer->send($p->email, $email['headers'], $email['body']);
434              
435             
436             if ($res === true) {
437                 // success....
438                 
439                 $successEventName = (empty($email['successEventName'])) ? 'NOTIFYSENT' : $email['successEventName'];
440                 
441                 $ev = $this->addEvent($successEventName, $w, "{$w->to_email} - {$email['headers']['Subject']}");
442                 
443                 $ev->writeEventLog($this->debug_str);
444                 
445                 if(strtotime($w->act_when) > strtotime("NOW")){
446                     $w->act_when = date('Y-m-d H:i:s');
447                 }
448                 
449                 $w->sent = (!$w->sent || $w->sent == '0000-00-00 00:00:00') ? $w->sqlValue('NOW()') : $w->sent; // do not update if sent.....
450                 $w->msgid = $email['headers']['Message-Id'];
451                 $w->event_id = $ev->id; // sent ok.. - no need to record it..
452                 $w->domain_id = $core_domain->id;
453                 $w->update($ww);
454                 
455                 // enable cc in notify..
456                 if (!empty($email['headers']['Cc'])) {
457                     $cmailer = Mail::factory('smtp',  isset($ff->Mail) ? $ff->Mail : array() );
458                     $email['headers']['Subject'] = "(CC): " . $email['headers']['Subject'];
459                     $cmailer->send($email['headers']['Cc'],
460                                   $email['headers'], $email['body']);
461                     
462                 }
463                 
464                 if (!empty($email['bcc'])) {
465                     $cmailer = Mail::factory('smtp', isset($ff->Mail) ? $ff->Mail : array() );
466                     $email['headers']['Subject'] = "(CC): " . $email['headers']['Subject'];
467                     $res = $cmailer->send($email['bcc'],
468                                   $email['headers'], $email['body']);
469                     if (!$res || is_a($res, 'PEAR_Error')) {
470                         echo "could not send bcc..\n";
471                     } else {
472                         echo "Sent BCC to {$email['bcc']}\n";
473                     }
474                 }
475                 
476                 
477                 $this->errorHandler(date('Y-m-d h:i:s') . " - SENT {$w->id} - {$w->to_email} \n", true);
478             }
479             // what type of error..
480             $code = empty($res->userinfo['smtpcode']) ? -1 : $res->userinfo['smtpcode'];
481             if (!empty($res->code) && $res->code == 10001) {
482                 // fake greylist if timed out.
483                 $code = 421;
484             }
485             
486             if ($code < 0) {
487                 $this->debug($res->message);
488                 continue; // try next mx... ??? should we wait??? - nope we did not even connect..
489             }
490             // give up after 2 days..
491             if (in_array($code, array( 421, 450, 451, 452))   && $next_try_min < (2*24*60)) {
492                 // try again later..
493                 // check last event for this item..
494                 //$errmsg=  $fail ? ($res->userinfo['smtpcode'] . ': ' .$res->toString()) :  " - UNKNOWN ERROR";
495                 $errmsg=  $res->userinfo['smtpcode'] . ': ' .$res->message ;
496                 if (!empty($res->userinfo['smtptext'])) {
497                     $errmsg=  $res->userinfo['smtpcode'] . ':' . $res->userinfo['smtptext'];
498                 }
499                 //print_r($res);
500                 $this->addEvent('NOTIFY', $w, 'GREYLISTED - ' . $errmsg);
501                 $w->act_when = date('Y-m-d H:i:s', strtotime('NOW + ' . $retry . ' MINUTES'));
502                 $this->updateServer($w);
503                 $w->domain_id = $core_domain->id;
504                 $w->update($ww);
505                 
506                 
507                 $this->errorHandler(date('Y-m-d h:i:s') . " - GREYLISTED -  $errmsg \n");
508             }
509             $fail = true;
510             break;
511         }
512         if ($fail || $next_try_min > (2*24*60)) {
513         // fail.. = log and give up..
514             $errmsg=  $fail ? ($res->userinfo['smtpcode'] . ': ' .$res->toString()) :  " - UNKNOWN ERROR";
515             if (isset($res->userinfo['smtptext'])) {
516                 $errmsg=  $res->userinfo['smtpcode'] . ':' . $res->userinfo['smtptext'];
517             }
518             
519             $ev = $this->addEvent('NOTIFYFAIL', $w, ($fail ? "FAILED - " : "RETRY TIME EXCEEDED - ") .
520                        $errmsg);
521             $w->sent = (!$w->sent || $w->sent == '0000-00-00 00:00:00') ? $w->sqlValue('NOW()') : $w->sent; // do not update if sent.....
522             $w->msgid = '';
523             $w->event_id = $ev->id;
524             $w->domain_id = $core_domain->id;
525             $w->update($ww);
526             $this->errorHandler(date('Y-m-d h:i:s') . ' - FAILED - '. ($fail ? $res->toString() : "RETRY TIME EXCEEDED\n"));
527         }
528         
529         // handle no host availalbe forever...
530         if (strtotime($w->act_start) < strtotime('NOW - 3 DAYS')) {
531             $ev = $this->addEvent('NOTIFYFAIL', $w, "RETRY TIME EXCEEDED - ". $p->email);
532             $w->sent = (!$w->sent || $w->sent == '0000-00-00 00:00:00') ? $w->sqlValue('NOW()') : $w->sent; // do not update if sent.....
533             $w->msgid = '';
534             $w->event_id = $ev->id;
535             $w->domain_id = $core_domain->id;
536             $w->update($ww);
537             $this->errorHandler(date('Y-m-d h:i:s') . " - FAILED - RETRY TIME EXCEEDED\n");
538         }
539         
540         
541         $this->addEvent('NOTIFY', $w, 'NO HOST CAN BE CONTACTED:' . $p->email);
542         $w->act_when = date('Y-m-d H:i:s', strtotime('NOW + ' . $retry . ' MINUTES'));
543         
544         $this->updateServer($w);
545         
546         $w->domain_id = $core_domain->id;
547         $w->update($ww);
548         $this->errorHandler(date('Y-m-d h:i:s') ." - NO HOST AVAILABLE\n");
549
550         
551     }
552     function mxs($fqdn)
553     {
554         $ff = HTML_FlexyFramework::get();
555         if (isset($ff->Pman_Core_NotifySend['host'])) {
556             return array($ff->Pman_Core_NotifySend['host']);
557         }
558         
559         $mx_records = array();
560         $mx_weight = array();
561         $mxs = array();
562         if (!getmxrr($fqdn, $mx_records, $mx_weight)) {
563             if (!checkdnsrr($fqdn)) {
564                 return false;
565             }
566             return array($fqdn);
567         }
568         
569         asort($mx_weight,SORT_NUMERIC);
570         
571         foreach($mx_weight as $k => $weight) {
572             if (!empty($mx_records[$k])) {
573                 $mxs[] = $mx_records[$k];
574             }
575         }
576         return empty($mxs) ? false : $mxs;
577     }
578     
579     /**
580      * wrapper to call object->toEmail()
581      *
582      * return
583      *   {
584         headers : {AssocArray},
585         body: {String}
586         
587         // optional..
588         error :  {String} // error message in log.
589         send-to: {String} // use to override rcpt
590          
591      }
592      **/
593     function makeEmail($object, $rcpt, $last_sent_date, $notify, $force =false)
594     {
595         $m = 'notify'. $notify->evtype;
596         //var_dump(get_class($object) . '::' .$m);
597         if (!empty($notify->evtype) && method_exists($object,$m)) {
598             echo "calling :" . get_class($object) . '::' .$m . "\n";
599             return $object->$m($rcpt, $last_sent_date, $notify, $force);
600         }
601         
602         $type = explode('::', $notify->evtype);
603         
604         if(!empty($type[1]) && method_exists($object,$type[1])){
605             $m = $type[1];
606             echo "calling :" . get_class($object) . '::' .$m . "\n";
607             return $object->$m($rcpt, $last_sent_date, $notify, $force);
608         }
609         // fallback if evtype is empty..
610         
611         if (method_exists($object, 'toMailerData')) {
612             return $object->toMailerData(array(
613                 'rcpts'=>$rcpt,
614                 'person'=>$rcpt, // added as mediaoutreach used this?
615             )); //this is core_email - i think it's only used for testing...
616             //var_Dump($object);
617             //exit;
618         }
619         if (method_exists($object, 'toEmail')) {
620             return $object->toEmail($rcpt, $last_sent_date, $notify, $force);
621         }
622         // no way to send this.. - this needs to handle core_notify how we have used it for the approval stuff..
623         
624         return false;
625     }
626     
627     function debug($str)
628     {
629         if (empty($this->cli_args['debug'])) {
630             return;
631             
632         }
633         echo $str . "\n";
634     }
635     function output()
636     {
637         $this->errorHandler("done\n");
638     }
639     var $debug_str = '';
640     
641     function debugHandler ($smtp, $message)
642     {
643         $this->debug_str .= strlen($this->debug_str) ? "\n" : '';
644         $this->debug_str .= $message;
645         //echo $message ."\n";
646     }
647     
648     function errorHandler($msg, $success = false)
649     {
650         if($this->error_handler == 'exception'){
651             if($success){
652                 throw new Pman_Core_NotifySend_Exception_Success($msg);
653             }
654             
655             throw new Pman_Core_NotifySend_Exception_Fail($msg);
656         }
657         
658         die($msg ."\n");
659         
660         
661     }
662     
663     function updateServer($w)
664     {
665         $ff = HTML_FlexyFramework::get();
666          
667         if (empty($ff->Core_Notify['servers'])) {
668             return;
669         }
670         // some classes dont support server routing
671         if (!property_exists($w, 'server_id')) {
672             return;
673         }
674         // next server..
675         $w->server_id = ($w->server_id + 1) % count(array_keys($ff->Core_Notify['servers']));
676          
677     }
678     
679
680     
681 }