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..4f000901f74d6d7c61730f3065b63760266dbb31 100644
--- a/include/class.filter.php
+++ b/include/class.filter.php
@@ -401,7 +401,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']);
        
 
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 39aaaae815a8479233e3959c26b4dc28764b1ef0..b9e50863072c57bd2e2ca8891641c297a80c67cf 100644
--- a/include/staff/cannedreplies.inc.php
+++ b/include/staff/cannedreplies.inc.php
@@ -83,7 +83,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 55e29db7d686880c5b3267f9803acfb94f83574b..8739e0771fda6d9aca32d772626adb344bb6ad81 100644
--- a/include/staff/cannedreply.inc.php
+++ b/include/staff/cannedreply.inc.php
@@ -107,6 +107,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 b23dd520bc8338ba4188162395f3045df6aaef3f..f57a09a42310d01b3297b38638453437084ca5de 100644
--- a/include/staff/filter.inc.php
+++ b/include/staff/filter.inc.php
@@ -186,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);
@@ -201,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>