diff --git a/include/class.thread.php b/include/class.thread.php
index dfd3bb314a06c982376038ace37ff19ebfea8c67..89a5d0af571a9645e39b570c147810ba5065632f 100644
--- a/include/class.thread.php
+++ b/include/class.thread.php
@@ -744,7 +744,7 @@ Class ThreadEntry {
         $subject = $mailinfo['subject'];
         $match = array();
         if ($subject && $mailinfo['email']
-                && preg_match("/#[\p{L}-]+?([0-9]{1,10})/u", $subject, $match)
+                && preg_match("/#(?:[\p{L}-]+)?([0-9]{1,10})/u", $subject, $match)
                 && ($tid = Ticket::getIdByExtId((int)$match[1], $mailinfo['email']))
                 )
             // Return last message for the thread
diff --git a/include/class.ticket.php b/include/class.ticket.php
index 199e4356a02ec6a09623d0e224b4860e379f9e92..7c816ff80cbcf6498d1e4925042141e15cab62dd 100644
--- a/include/class.ticket.php
+++ b/include/class.ticket.php
@@ -205,7 +205,7 @@ class Ticket {
 
     function getAuthToken() {
         # XXX: Support variable email address (for CCs)
-        return md5($this->getId() . $this->getEmail() . SECRET_SALT);
+        return md5($this->getId() . strtolower($this->getEmail()) . SECRET_SALT);
     }
 
     function getName(){