Added function to store emails in database