there's an email written for both Mary and John.
is it correct to use "Dear Both" at the beginning of the mail?
No. If you have the names, use them: Dear Mary and John.
so what should i use if i dont know the names?(but i know they are two persons)
An extremely unlikely scenario, but certainly not Dear Both, which sounds both odd and slightly rude. I would dispense with the greeting altogether, a common practice in this freewheeling virtual world of email and the Internet.