Messaging System: Save and Send - when to do the INSERT of a new message?
===

In a private messaging system built with PHP and MySQL users can compose new messages and answer to messages. There are two buttons: "SEND" and "SAVE". The message status is stored in the database (0=not yet sent, 1=sent). Also, the message is being saved automatically every e.g. 3 minutes via an ajax-call.

Sent messages as well as drafts are stored in the same table in the database. Now, when would you do the `INSERT INTO messages ...`?

If the user clicks on compose new message or answer? How to clean out all the never sent messages, if the user does not send the message, closes the window, presses the back-button?

What other options would you suggest?