You probably have multiple aims here:
- to be polite
- to avoid being considered ridiculous
- to get your email read
First of all, do your research: how is the person you wish to approach described on their institution's website? In extreme cases you might wish to consult a modern book of etiquette. For example, if you were addressing yourself to "Professor, the Right Honourable, the Lord X" you need to know that 'Dear Lord X' is fine and that 'My Lord' is now ridiculous.
Secondly, do not go over the top in honorific titles. (I still giggle at once being addressed as 'Your Excellency' in an unsolicited email.)
Thirdly avoid generic titles without a name, such as 'Dear Professor' or, even worse, 'Dear Doctor'. 'Dear Sir' might once have been OK, but these days it feels as if the writer has not done their research.
All of the above will probably permit you to avoid offending the recipient. But remember that, in the UK at least, a doctorate is not necessarily a requirement for a senior academic position. I have known very renowned, actually world famous, academics who never proceeded beyond an undergraduate degree and also some whose published books established a reputation before they had the chance to finish a formal doctorate so they never bothered. Some of those might have been mildly offended at being addressed as 'Doctor.'
All of this points to finding out something about the person to whom you wish to write before actually doing so.