"Notification event cleared (not required any more)"
."\n");
}
-
-
+ if (is_a($email, 'PEAR_Error')) {
+ $email =array(
+ 'error' => $email->toString()
+ );
+ }
- if ($email === false || isset($email['error'])) {
+ if (empty($p) && !empty($email['recipients'])) {
+ // make a fake person..
+ $p = (object) array(
+ 'email' => $email['recipients']
+ );
+ }
+
+ if ($email === false || isset($email['error']) || empty($p)) {
// object returned 'false' - it does not know how to send it..
$ev = $this->addEvent('NOTIFY', $w, isset($email['error']) ?
$email['error'] : "INTERNAL ERROR - We can not handle " . $w->ontable);
$email['headers']['Message-Id'] = "<{$this->table}-{$id}@{$HOST}>";
}
+
+
+
+
//$p->email = 'alan@akbkhome.com'; //for testing..
//print_r($email);exit;
// should we fetch the watch that caused it.. - which should contain the method to call..
if (!empty($opts['send-to'])) {
$p->email = $opts['send-to'];
}
- // since some of them have spaces?!?!
+
+ // since some of them have spaces?!?!
$p->email = trim($p->email);
+
require_once 'Validate.php';
if (!Validate::email($p->email, true)) {
$fail = false;
require_once 'Mail.php';
- foreach($mxs as $dom) {
-
-
+ foreach($mxs as $mx) {
if (!isset($ff->Mail['helo'])) {
$this->errorHandler("config Mail[helo] is not set");
}
$this->debug_str = '';
- $this->debug("Trying SMTP: $dom / HELO {$ff->Mail['helo']}");
+ $this->debug("Trying SMTP: $mx / HELO {$ff->Mail['helo']}");
$mailer = Mail::factory('smtp', array(
- 'host' => $dom ,
+ 'host' => $mx ,
'localhost' => $ff->Mail['helo'],
'timeout' => 15,
'socket_options' => isset($ff->Mail['socket_options']) ? $ff->Mail['socket_options'] : null,
// if the host is the mail host + it's authenticated add auth details
// this normally will happen if you sent Pman_Core_NotifySend['host']
- if (isset($ff->Mail['host']) && $ff->Mail['host'] == $dom && !empty($ff->Mail['auth'] )) {
+ if (isset($ff->Mail['host']) && $ff->Mail['host'] == $mx && !empty($ff->Mail['auth'] )) {
+
+ $username = $ff->Mail['username'] ;
+ $password = $ff->Mail['password'] ;
+
+ if(!empty($ff->Core_Notify)){
+
+ foreach ($ff->Core_Notify['routes'] as $server => $settings){
+ if(!in_array($dom, $settings['domains'])){
+ continue;
+ }
+
+ $mailer->host = $server;
+ $username = $settings['username'];
+ $password = $settings['password'];
+
+ break;
+ }
+
+ }
+
$mailer->auth = true;
- $mailer->username = $ff->Mail['username'] ;
- $mailer->password = $ff->Mail['password'] ;
+ $mailer->username = $username;
+ $mailer->password = $password;
}
$res = $mailer->send($p->email, $email['headers'], $email['body']);
}
- $this->errorHandler(date('Y-m-d h:i:s') . " - SENT\n");
+ $this->errorHandler(date('Y-m-d h:i:s') . " - SENT {$w->id} - {$w->to_email} \n");
}
// what type of error..
$code = empty($res->userinfo['smtpcode']) ? -1 : $res->userinfo['smtpcode'];
$w->event_id = $ev->id;
$w->update($ww);
$this->errorHandler(date('Y-m-d h:i:s') . " - FAILED - RETRY TIME EXCEEDED\n");
-
-
}