3 * Table Definition for core_notify_sender
5 class_exists('DB_DataObject') ? '' : require_once 'DB/DataObject.php';
7 class Pman_Core_DataObjects_Core_notify_sender extends DB_DataObject
10 /* the code below is auto generated do not remove the above tag */
12 public $__table = 'core_notify_sender'; // table name
13 public $id; // int(11) not_null primary_key auto_increment
21 function emailToSender($email , $notify)
23 require_once 'Mail/RFC822.php';
24 $parser = new Mail_RFC822();
25 $addresses = $parser->parseAddressList( $email['headers']['From'], 'localhost', false);
26 if (is_a($addresses, 'PEAR_Error')) {
29 $from_addr = $addresses[0];
30 //print_r($email['headers']['From']); print_R($from_addr);exit;
32 $from = $from_addr->mailbox . '@' . $from_addr->host;
34 $ns = DB_DataObject::Factory($this->tableName());
37 'poolname' => $notify->tableName()
39 if (!$ns->find(true)) {
49 function filterEmail($email, $notify)
52 if (empty($email['headers']['From']) || empty($notify)) {
55 $bits = explode('@', $notify->to_email);
56 $to_dom = DB_DataObject::factory('core_domain')->loadOrCreate($bits[1]);
59 $ns = $this->emailToSender($email, $notify);
64 $bl = DB_DAtaObject::Factory('core_notify_sender_blacklist');
66 'sender_id'=> $ns->id,
67 'domain_id' => $to_dom->id
73 // try finding alternative.
74 $bl = DB_DAtaObject::Factory('core_notify_sender_blacklist');
75 $bl->domain_id = $to_dom->id;
76 $bad_ids = $bl->fetchAll('sender_id');
78 $ns = DB_DataObject::Factory($this->tableName());
83 $ns->whereAddIn('!id', $bad_ids, 'int');
85 return $email; // no alternative available
89 $mail['headers']['From'] = $from_addr->personal . ' <' . $ns->email .'>';
99 function checkSmtpResponse($email, $notify, $errmsg)
101 $bl = DB_DataObject::factory('core_notify_sender_blacklist');
102 if (!$bl->messageIsBlacklisted($errmsg)) {
107 $bits = explode('@', $notify->to_email);
108 $to_dom = DB_DataObject::factory('core_domain')->loadOrCreate($bits[1]);
110 $ns = $this->emailToSender($email);
112 'sender_id' => $ns->id,
113 'domain_id' => $to_dom->id,
118 $bl->error_msg = $errmsg;
119 $bl->added_dt = $bl->sqlValue('NOW()');