I have a website with a contact form. User submits name, email and message and the site emails me the details.
Very occasionally my server has a problem with it's email system and so the user gets an error and those contact details are lost. (Don't say: get a better server, any server can have email go down now and then and we do get a lot of submissions).
I would like to implement a system that could store the user's details if the mail sending function returns with an error code. Then on every further submission, check for any stored submissions and try to send them off to me.
But how to store the data?
I'm using python so I thought about using shelve (single file semi-database). Or maybe someone could suggest a better data format? (I do think a full database solution would be overkill.)
The problem I see with a single file approach is race-conditions: two or more failed emails at the same time would cause two edits to the data file resulting in data corruption.
So what to do? Multi-file solution, file locking or something else?