Support terminating maildelivery service while connecting/sending

If the maildelivery service was in the process of trying to connect to
the SMTP server or trying to deliver a mail, it would try forever until
successful, and while doing so, wouldn't respond to requests to stop
(or restart.)

Change the "while True:" loops into "while not self.terminated:" to
make the service more responsive.  There's no risk of data loss to stop
in the middle of trying to deliver a mail; the mail is kept in the
outbox until it's successfully delivered, so the service would try to
deliver it again when restarted.

Also set a timeout (default 10 seconds) on the smtplib.SMTP() object,
to prevent it from getting stuck for a very long time in blocking calls,
during which the service still might refuse to terminate.
Parse incoming mail (during testing) using email.parser

Should be more robust.
Check that mailbox is empty at end of testing

Unexpected mails would almost certainly be "administrator messages"
indicating problems in background services, and those should be logged
as errors in testing.
Improve testing.mailbox.Mailbox implementation

When client sends "quit" command, reply appropriately and close the
connection.  Not doing so typically leaves the client waiting
indefinitely.