How to ask for employment help or referral from someone you don't know?
The typical approach is to send an email saying something like:


  Dear Dr. M.,
  
  My name is ... and I am applying for the position of ... in your department.  (Brief summary of your professional background and research interests.)  I am particularly interested in the position because I would look forward to the opportunity to collaborate with you.  Please let me know if there's anything you want to discuss.  My CV is attached (maybe also a preprint).


This alerts Dr. M to the fact you are applying, so that he can get in touch with the search committee if he wants to support your application.

However, normally you would do this at roughly the same time as you submit the application.  You say you applied three months ago, but when is the application deadline?  If it hasn't passed yet, or if it was just a few days ago, then there might still be time for an email to Dr. M to have some effect.

But if it passed some time ago, then the search committee has probably already finished one or more rounds of screening.  If that's the case, and you haven't been invited to interview or otherwise contacted, then unfortunately, you probably didn't make the initial cut.  In that case there is very little that Dr. M can do, so not much point in contacting him.

(By the way, it's pretty much irrelevant that your advisor went to the same university as Dr. M, if they haven't otherwise been in contact.  That kind of relationship is roughly comparable to this one.  So I'd leave it out of any message.)