Answer
$T= \frac{M~m~g}{M+m}$
Work Step by Step
Let's consider the system of block $m$. We can set up a force equation for this block.
$\sum F = ma$
$mg - T = ma$
$a = \frac{mg-T}{m}$
We can use this expression for $a$ in the force equation for the block of mass $M$. Note that both blocks have the same magnitude of acceleration.
$T = Ma$
$T = (M)(\frac{mg-T}{m})$
$mT +MT= M~m~g$
$T= \frac{M~m~g}{M+m}$