Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
"Global variables aren't available in the function scope unless you specifically ask for them with the global keyword." Incorrect, you can access them using $GLOBAL keyword, yes that "might" be disabled but highly unlikely, using the global keyword iirc is deprecated or should be if nothing else.
@Pawel Dyda A reset link can also be sniffed, if your email is getting sniffed i think having a temp password in your email is the least of your worries.