added server side code for saving emails