Well here's the thing:
If you want to use just the username prior to the @ symbol, use the above code.
To use an alias or different username, you'll have to use either virtuser_query or the virtuser_table entries. The virtuser table, I'm not sure about. The query would look something like:
SELECT emailaddress
FROM users
WHERE alias = '$inputalias'
LIMIT 0, 1