In the function getSgMailto(), the default username variable is "defaultusername", while it's defined above as "defaultsguser". Changing it to "defaultusername" where it's declared fixes the problem.
Just a head's up to anyone using the demo code.
(Thanks again for something like 11 years of spam-eating. You guys are my favorite people in the whole world.)