emails: Allow specifying how deep to recurse

Previously, the mail parsing and fetching system would recurse unbounded
searching for bodies by content-type
emails: Mail_Parse detects bounce emails
Ticket thread supports specifying `thread-type`

This allows the email system to detect something like a bounce mail and
specify that the associated message should be an internal note.
emails: Add bounce detection for mail fetching
Remove bit-rotted code
Hide close/hide dialog when esc key is pressed
Timeout after max timeout while fetching emails

Processing fetching in ASC order of the last fetch time
Remove LIMIT of 10 emails per fetch
Flush the buffer and terminate the request cleanly on autocron
forms: Fix ticket submission if already logged in

If a client is already logged into the client portal and attempts to submit
a new ticket, the ticket will be rejected if the contact-information form
has a required field other than `name` and `email`.

This patch fixes `class Client` so that the user-id is fetched from the
database and made available via the `::getUserId()` method. This was already
corrected in the `develop-next` branch for v1.8.1. The `uid` field is passed
into `Ticket::create()` so the user form validation is bypassed.

This commit should be ignored when merged into the 1.8.1 codebase.
Merge pull request #469 from greezybacon/issue/logged-in-client

forms: Fix ticket submission if already logged in

Reviewed-By: Peter Rotich <peter@osticket.com>
Merge pull request #465 from slm4996/feature/popups

Hide close/hide dialog when esc key is pressed fixes issue #441

Reviewed-By: Jared Hancock <jared@osticket.com>
Merge pull request #468 from protich/feature/mailfetch

Timeout after max timeout while fetching emails

Reviewed-By: Jared Hancock <jared@osticket.com>
Reviewed-By: Alan Wilkes
Add Return-Path header for outbound SMTP mail
Merge pull request #461 from greezybacon/feature/handle-bounce-mails

Handle email bounce notifications

Reviewed-By: Peter Rotich <peter@osticket.com>
Merge remote branch 'upstream/develop' into develop-next

Conflicts:
	include/api.tickets.php
	include/class.client.php
	include/class.mailfetch.php
	include/class.thread.php
	open.php