$CustomerEmail is only defined within the brackets following the if statement. Something called scope. All you need to do is to initialize it outside of the brackets.
<?php
$CustomerEmail = '';
if (Mage:: ....
And where did you come across this Mage framework? Seems a bit dated to say the least.