}
if (!$force && !empty($w->sent) && strtotime($w->act_when) < strtotime($w->sent)) {
-
-
- $this->errorHandler("send repeat to early\n");
+
+ $this->errorHandler("already sent - repeat to early\n");
}
if (!empty($opts['debug'])) {
print_r($w);
if (isset($email['later'])) {
$old = clone($w);
$w->act_when = $email['later'];
+ $this->updateServer($w);
$w->update($old);
$this->errorHandler(date('Y-m-d h:i:s ') . " Delivery postponed by email creator to {$email['later']}");
}
// need to handle temporary failure..
- // we try for 3 days..
- $retry = 5;
+ // we try for 2 days..
+ $retry = 15;
if (strtotime($w->act_start) < strtotime('NOW - 1 HOUR')) {
// older that 1 hour.
- $retry = 15;
+ $retry = 60;
}
if (strtotime($w->act_start) < strtotime('NOW - 1 DAY')) {
// older that 1 day.
- $retry = 60;
+ $retry = 120;
}
if (strtotime($w->act_start) < strtotime('NOW - 2 DAY')) {
// older that 1 day.
- $retry = 120;
+ $retry = 240;
}
- if ($mxs === false) {
- // only retry for 2 day son the MX issue..
- if ($retry < 120) {
+ if (empty($mxs)) {
+ // only retry for 1 day if the MX issue..
+ if ($retry < 240) {
$this->addEvent('NOTIFY', $w, 'MX LOOKUP FAILED ' . $dom );
$w->act_when = date('Y-m-d H:i:s', strtotime('NOW + ' . $retry . ' MINUTES'));
+ $this->updateServer($w);
$w->update($ww);
- $this->errorHandler(date('Y-m-d h:i:s') . " - MX LOOKUP FAILED\n");
+ $this->errorHandler(date('Y-m-d h:i:s') . " - MX LOOKUP FAILED {$dom}\n");
}
$ev = $this->addEvent('NOTIFYFAIL', $w, "BAD ADDRESS - BAD DOMAIN - ". $p->email );
$w->event_id = $ev->id;
$w->to_email = $p->email;
$w->update($ww);
- $this->errorHandler(date('Y-m-d h:i:s') . " - FAILED - BAD EMAIL - {$p->email} \n");
+ $this->errorHandler(date('Y-m-d h:i:s') . " - FAILED - BAD DOMAIN - {$p->email} \n");
}
- if (!$force && strtotime($w->act_start) < strtotime('NOW - 14 DAY')) {
+ if (!$force && strtotime($w->act_start) < strtotime('NOW - 3 DAY')) {
$ev = $this->addEvent('NOTIFYFAIL', $w, "BAD ADDRESS - GIVE UP - ". $p->email );
$w->sent = $w->sqlValue('NOW()');
$w->msgid = '';
$w->to_email = $p->email;
//$this->addEvent('NOTIFY', $w, 'GREYLISTED ' . $p->email . ' ' . $res->toString());
// we can only update act_when if it has not been sent already (only happens when running in force mode..)
+ // set act when if it's empty...
$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;
+
$w->update($ww);
$ww = clone($w);
));
$core_domain->insert();
}
+
+
+ $this->initHelo();
+
+ if (!isset($ff->Mail['helo'])) {
+ $this->errorHandler("config Mail[helo] is not set");
+ }
+
+
foreach($mxs as $mx) {
- if (!isset($ff->Mail['helo'])) {
- $this->errorHandler("config Mail[helo] is not set");
- }
+
$this->debug_str = '';
$this->debug("Trying SMTP: $mx / HELO {$ff->Mail['helo']}");
$mailer = Mail::factory('smtp', array(
if($core_notify->count()){
$old = clone($w);
$w->act_when = date("Y-m-d H:i:s", time() + $seconds);
+ $this->updateServer($w);
$w->update($old);
$this->errorHandler(date('Y-m-d h:i:s ') . " Too many emails sent by {$dom}");
}
//print_r($res);
$this->addEvent('NOTIFY', $w, 'GREYLISTED - ' . $errmsg);
$w->act_when = date('Y-m-d H:i:s', strtotime('NOW + ' . $retry . ' MINUTES'));
+ $this->updateServer($w);
$w->domain_id = $core_domain->id;
$w->update($ww);
$this->addEvent('NOTIFY', $w, 'NO HOST CAN BE CONTACTED:' . $p->email);
- $w->act_when = date('Y-m-d H:i:s', strtotime('NOW + 5 MINUTES'));
+ $w->act_when = date('Y-m-d H:i:s', strtotime('NOW + ' . $retry . ' MINUTES'));
+
+ $this->updateServer($w);
+
$w->domain_id = $core_domain->id;
$w->update($ww);
$this->errorHandler(date('Y-m-d h:i:s') ." - NO HOST AVAILABLE\n");
asort($mx_weight,SORT_NUMERIC);
foreach($mx_weight as $k => $weight) {
- $mxs[] = $mx_records[$k];
+ if (!empty($mx_records[$k])) {
+ $mxs[] = $mx_records[$k];
+ }
}
- return $mxs;
+ return empty($mxs) ? false : $mxs;
}
/**
}
+
+ function updateServer($w)
+ {
+ $ff = HTML_FlexyFramework::get();
+
+ if (empty($ff->Core_Notify['servers'])) {
+ return;
+ }
+ // some classes dont support server routing
+ if (!property_exists($w, 'server_id')) {
+ return;
+ }
+ // next server..
+ $w->server_id = ($w->server_id + 1) % count(array_keys($ff->Core_Notify['servers']));
+
+ }
+
+ function initHelo()
+ {
+ $ff = HTML_FlexyFramework::get();
+
+ if (isset($ff->Core_Notify['servers-non-pool']) &&
+ isset($ff->Core_Notify['servers-non-pool'][gethostname()]) &&
+ isset($ff->Core_Notify['servers-non-pool'][gethostname()]['helo']) ) {
+ $ff->Mail['helo'] = $ff->Core_Notify['servers-non-pool'][gethostname()]['helo'];
+ return;
+ }
+
+ if (empty($ff->Core_Notify['servers'])) {
+ return;
+ }
+ if (!isset($ff->Core_Notify['servers'][gethostname()]) || !isset($ff->Core_Notify['servers'][gethostname()]['helo']) ) {
+ $this->jerr("Core_Notify['servers']['" . gethostname() . "']['helo'] not set");
+ }
+ $ff->Mail['helo'] = $ff->Core_Notify['servers'][gethostname()]['helo'];
+
+ }
+
}
\ No newline at end of file