Let $S$ be submanifold of $M$ such that every smooth function f : S → R has a smooth extension to a neighborhood U of of $S$ in M.
My attempt: I have shown that under the given condition $S$ ie embedded submanifold. Thus it suffice to show that $S$ is closed in $M$ to show that $S$ is properly embeddded. Suppose $S$ is not closed in $M$. Then there is a point $p\in \overline S-S$. If I can construct a smooth function on $M$ that is zero only at $p$, then $\frac{1}{f}$ is smooth on $S$ but has no extension to all of $M$ since $p$ is a limit point of $S$. Please provide me some hints.
Take a smooth function $h\colon \mathbb{R}^n\rightarrow [0,1]$ with $h(0)=1$ and $h(x)<1$ for $x\neq 0$. (For example $h(x)=\exp(-\vert x\vert^2/(1-\vert x\vert^2))$ for $\vert x\vert <1$ and $\equiv 0$ otherwise).
Then choose a chart $(U,\varphi\colon U\xrightarrow{\sim}\mathbb{R}^n)$ of $M$ with $\varphi(p)=0$ and put $f(q)=1-h(\varphi(q))$ for $q\in U$ and $f(q)=1$ if $q\notin U.$ Then $f$ is smooth on all of $M$ and only vanishes in $p$.