diff --git a/include/class.canned.php b/include/class.canned.php
index 09a3877ada46bb507b649e65294bc6c0430399dd..399b490d3a9cf3c1832fc4892c66ccd4aed06f6f 100644
--- a/include/class.canned.php
+++ b/include/class.canned.php
@@ -31,9 +31,11 @@ class Canned {
         if(!$id && !($id=$this->getId()))
             return false;
 
-        $sql='SELECT canned.*, count(attach.file_id) as attachments '
+        $sql='SELECT canned.*, count(attach.file_id) as attachments, '
+            .' count(filter.id) as filters '
             .' FROM '.CANNED_TABLE.' canned '
             .' LEFT JOIN '.CANNED_ATTACHMENT_TABLE.' attach ON (attach.canned_id=canned.canned_id) ' 
+            .' LEFT JOIN '.EMAIL_FILTER_TABLE.' filter ON (canned.canned_id = filter.canned_response_id) '
             .' WHERE canned.canned_id='.db_input($id);
         if(!($res=db_query($sql)) ||  !db_num_rows($res))
             return false;
@@ -62,6 +64,9 @@ class Canned {
         return $this->isEnabled();
     }
 
+    function getNumFilters() {
+        return $this->ht['filters'];
+    }
     
     function getTitle() {
         return $this->ht['title'];
@@ -91,6 +96,19 @@ class Canned {
         return $this->getHashtable();
     }
 
+    function getFilters() {
+        if (!$this->_filters) {
+            $this->_filters = array();
+            $res = db_query(
+                  'SELECT name FROM '.EMAIL_FILTER_TABLE
+                .' WHERE canned_response_id = '.db_input($this->getId())
+                .' ORDER BY name');
+            while ($row = db_fetch_row($res))
+                $this->_filters[] = $row[0];
+        }
+        return $this->_filters;
+    }
+
     function update($vars, &$errors) {
 
         if(!$this->save($this->getId(),$vars,$errors))
@@ -168,6 +186,7 @@ class Canned {
     }
 
     function delete(){
+        if ($this->getNumFilters() > 0) return false;
 
         $sql='DELETE FROM '.CANNED_TABLE.' WHERE canned_id='.db_input($this->getId()).' LIMIT 1';
         if(db_query($sql) && ($num=db_affected_rows())) {
diff --git a/include/class.filter.php b/include/class.filter.php
index a749e5eaeabc6c08d0a44d29fa30782511313bac..bc9b0847132aff00f794dd74abf6b2ec71379e35 100644
--- a/include/class.filter.php
+++ b/include/class.filter.php
@@ -71,6 +71,10 @@ class Filter {
         return $this->ht['execorder'];
     }
 
+    function getEmailId() {
+        return $this->ht['email_id'];
+    }
+
     function isActive(){
         return ($this->ht['isactive']);
     }
@@ -216,11 +220,11 @@ class Filter {
      */
     function matches($email) {
         $what = array(
-            "email"     => $email['from'],
+            "email"     => $email['email'],
             "subject"   => $email['subject'],
             # XXX: Support reply-to too ?
             "name"      => $email['name'],
-            "body"      => $email['body']
+            "body"      => $email['message']
             # XXX: Support headers
         );
         $how = array(
@@ -231,6 +235,10 @@ class Filter {
             "dn_contain"=> array("strpos", false)
         );
         $match = false;
+        # Respect configured filter email-id
+        if ($email['emailId'] && $this->getEmailId()
+                && $this->getEmailId() != $email['emailId'])
+            return false;
         foreach ($this->getRules() as $rule) {
             list($func, $pos, $neg) = $how[$rule['h']];
             # TODO: convert $what and $rule['v'] to mb_strtoupper and do
@@ -281,6 +289,22 @@ class Filter {
         if ($this->getCannedResponse())
             $ticket['cannedResponseId'] = $this->getCannedResponse();
     }
+    /* static */ function getSupportedMatches() {
+        return array(
+            'name'=>    "Sender's Name",
+            'email'=>   "Sender's Email",
+            'subject'=> 'Email Subject',
+            'body'=>    'Email Body/Text'
+        );
+    }
+    /* static */ function getSupportedMatchTypes() {
+        return array(
+            'equal'=>       'Equal',
+            'not_equal'=>   'Not Equal',
+            'contains'=>    'Contains',
+            'dn_contain'=>  'Does Not Contain'
+        );
+    }
 
     function update($vars,&$errors){
 
@@ -401,7 +425,7 @@ class Filter {
              ',reject_email='.db_input(isset($vars['reject_email'])?1:0).
              ',use_replyto_email='.db_input(isset($vars['use_replyto_email'])?1:0).
              ',disable_autoresponder='.db_input(isset($vars['disable_autoresponder'])?1:0).
-             ',canned_response_id='.db_input($vars['canned_response']).
+             ',canned_response_id='.db_input($vars['canned_response_id']).
              ',notes='.db_input($vars['notes']);
        
 
@@ -567,7 +591,7 @@ class EmailFilter {
      * calls, etc).
      *
      * $email is an ARRAY, which has valid keys
-     *  *from - email address of sender
+     *  *email - email address of sender
      *   name - name of sender
      *   subject - subject line of the email
      *   email-id - id of osTicket email recipient address
@@ -586,8 +610,8 @@ class EmailFilter {
             $this->build($this->getAllActive());
         } else {
             $this->build(
-                $this->quickList($email['from'], $email['name'],
-                    $email['subject']));
+                $this->quickList($email['email'], $email['name'],
+                    $email['subject'], $email['emailId']));
         }
     }
     
diff --git a/include/class.ticket.php b/include/class.ticket.php
index 683ab25c46e69e83e0150baee01c329e90c5f7e4..42bb1737840d4c489f92ec128b918732d2a1ac77 100644
--- a/include/class.ticket.php
+++ b/include/class.ticket.php
@@ -2018,7 +2018,8 @@ class Ticket{
         $ticket->onNewTicket($vars['message'], $autorespond, $alertstaff);
 
         if ($vars['cannedResponseId']
-                && ($canned = Canned::lookup($vars['cannedResponseId']))) {
+                && ($canned = Canned::lookup($vars['cannedResponseId']))
+                && $canned->isEnabled()) {
             $files = array();
             foreach ($canned->getAttachments() as $file)
                 $files[] = $file['id'];
diff --git a/include/staff/cannedreplies.inc.php b/include/staff/cannedreplies.inc.php
index 5464bf8d699083091e02faf35ce6e967c8a01c8b..2f19cbd194a1ee7570fcda67eca30f295bc1d2fa 100644
--- a/include/staff/cannedreplies.inc.php
+++ b/include/staff/cannedreplies.inc.php
@@ -84,7 +84,8 @@ else
                 <td width=7px>
                   <input type="checkbox" name="ids[]" value="<?php echo $row['canned_id']; ?>"
                             <?php echo $sel?'checked="checked"':''; ?>  <?php echo $default?'disabled="disabled"':''; ?>
-                                onClick="highLight(this.value,this.checked);"> </td>
+                                onClick="highLight(this.value,this.checked);"/>
+                </td>
                 <td>
                     <a href="canned.php?id=<?php echo $row['canned_id']; ?>"><?php echo Format::truncate($row['title'],200); echo "&nbsp;$files"; ?></a>&nbsp;
                 </td>
diff --git a/include/staff/cannedreply.inc.php b/include/staff/cannedreply.inc.php
index 4e87d5854f9e7e64abfb69a69511abbf061cd6b1..f18b114a2225fde48d9bddbc73ff3ec93e5a3fd4 100644
--- a/include/staff/cannedreply.inc.php
+++ b/include/staff/cannedreply.inc.php
@@ -108,6 +108,11 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info);
         </tr>
     </tbody>
 </table>
+ <?php if ($canned && $canned->getFilters()) { ?>
+    <br/>
+    <div id="msg_warning">Canned reply is in use by email filter(s): <?php
+    echo implode(', ', $canned->getFilters()); ?></div>
+ <?php } ?>
 <p style="padding-left:225px;">
     <input type="submit" name="submit" value="<?php echo $submit_text; ?>">
     <input type="reset"  name="reset"  value="Reset">
diff --git a/include/staff/filter.inc.php b/include/staff/filter.inc.php
index 89ca2c41ffc3b02945bdb4619391ea815cf13821..c2aad0bcf4456d5bade4fa323a4ba3c991c39929 100644
--- a/include/staff/filter.inc.php
+++ b/include/staff/filter.inc.php
@@ -1,9 +1,8 @@
 <?php
 if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied');
 
-$matches=array('name'=>"Sender's Name",'email'=>"Sender's Email",'subject'=>'Email Subject','body'=>'Email Body/Text','header'=>'Email Header');
-$match_types=array('equal'=>'Equal','not_equal'=>'Not Equal','contains'=>'Contains','dn_contain'=>'Does Not Contain');
-
+$matches=Filter::getSupportedMatches();
+$match_types=Filter::getSupportedMatchTypes();
 
 $info=array();
 $qstr='';
@@ -187,14 +186,15 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info);
                 Canned Response:
             </td>
                 <td>
-                <select name="canned_response">
+                <select name="canned_response_id">
                     <option value="">&mdash; None &mdash;</option>
                     <?php
-                    $sql='SELECT canned_id,title FROM '.CANNED_TABLE.' ORDER by title';
+                    $sql='SELECT canned_id,title FROM '.CANNED_TABLE
+                        .' WHERE isenabled ORDER by title';
                     if ($res=db_query($sql)) {
                         while (list($id,$title)=db_fetch_row($res)) {
-                            $selected=($info['canned_response'] &&
-                                    $id==$info['canned_response'])
+                            $selected=($info['canned_response_id'] &&
+                                    $id==$info['canned_response_id'])
                                 ? 'selected="selected"' : '';
                             echo sprintf('<option value="%d" %s>%s</option>',
                                 $id, $selected, $title);
@@ -202,7 +202,7 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info);
                     }
                     ?>
                 </select>
-                <em>(Automatically respond with this canned attachment)</em>
+                <em>(Automatically respond with this canned response)</em>
             </td>
         </tr>
         <tr>