# How to test X affects Y through M

Have a simple question. I have a dep. variable Y and an independent variable, X. X also affects another binary variable M and M affects Y. I want to show that X affects Y through M. M is exogenous. This is my strategy. In Step 1, I estimate a uni variate logit model of M on X. Get the predicted values. This is the portion of M that is explained by X only. I then use these predicted values as an independent variable to predict Y. If the coefficient is significant, I know X affects Y through M. Is this ok? Is there a cite or reference to show this can be done.