Let's start from the beginning. You got your Mac back and you restored it from Time Machine, and that was broken? (ie Safari failed to run).
How did you Restore from TM? Please link to a tutorial you followed or list the steps you took.
What OS did they install on the new Hard Drive?
What OS did you try to Restore?
What OS shipped with the iMac?
You got your Mac back and you restored it from Time Machine, and that was broken? (ie Safari failed to run). - Yes
What OS did they install on the new Hard Drive? - Mountain
What OS did you try to Restore? - I'm not trying to restore anything, just wanted my emails and smart email boxes that I lost from upgrading to Mountain Lion back.
What OS shipped with the iMac? - Mountain
If you didn't Restore your whole drive via Time Machine, what exactly did you restore and how?
You originally said, "so I thought it's time to upfgrade to Mountain Lion and what a mistake."
But in your reply, you said Mountain Lion shipped with the iMac, so how was that an "upgrade" to Mountain Lion?
I'm trying to figure out what exactly could cause the problem you describe, and these inconsistencies don't help.
My advice would be to use Disk Utility on the Recovery HD and erase the disk. Then, reinstall Mountain Lion.
When it runs the startup program, it will ask if you want to recover from another Mac or Time Machine, choose to migrate from a Time Machine backup. That should create the same account name and password, along with all of your data and applications. If you have all of your install media, you might consider just restoring the Data and not Applications. Install the applications after you have a working system and all your email is restored.