The 'unique' calculation for the 32 character id for each message was based on microtime(). Apparently your server sends messages faster than 1 per microsecond.. !
I have modified your calculation code to that indicated on php.net here:
http://php.net/uniqid// better, difficult to guess
$better_token = md5(uniqid(rand(), true));
Duplicates should be far, far more rare, if ever... I'll have to consider how to improve this process. To save time I didn't want to check each ID for a duplicate value but I might have to to prevent even rare occurrences of duplicates...
Regards