Converted mail api to new database object