Is this proof correct?
Suppose $M$ is not connected. Then $M$ is disjoint union of two non empty open sets $U$ and $V$. Take $x\in U$, $y \in V$ joined by a path $\gamma:[0,1]\rightarrow M$.
$\gamma([0,1])$ is partitioned by wether an element is in $U$ or in $V$.
If there are more then on interval in $U$ and in $V$, again, restrict $\gamma$ and redefine $x\in U$ and $y\in V$ if necessary. i.e. $\gamma([0,\epsilon])\subset U$ and $\gamma(]\epsilon,1])\in V$ or $\gamma([0,\epsilon[)\subset U$ and $\gamma([\epsilon,1])\in V$.
But then, in the first case, $\gamma^{-1}(V) = ]\epsilon,1]$ which is a contradiction since $V$ is open and $]\epsilon,1]$ is closed. In the second case, $\gamma^{-1}(U) = [0,\epsilon[$ which is a contradiction since $U$ is open and $[0,\epsilon[$ is closed.
The proof is more simple: $[0,1]$ is partitioned into disjoint non-empty open subsets $\gamma^{-1}(U)$ and $\gamma^{-1}(V)$, which is impossible.