This patch:
1. Copies unsent messages to the outbox before attempting to deliver
them with SMTP
2. Deletes those messages once they're sent, or leaves them if an error
occured
3. Updates the message list to make it obvious when there are unsent
messages in the outbox
This one is a bit of a doozy. A summary of the changes:
- Session has grown storage for attachments which have been uploaded but
not yet sent.
- The list of attachments on a message is refcounted so that we can
clean up the temporary files only after it's done with - i.e. after
copying to Sent and after all of the SMTP attempts are done.
- Abandoned attachments are cleared out on process shutdown.
Future work:
- Add a limit to the maximum number of pending attachments the user can
have in the session.
- Periodically clean out abandoned attachments?