I'm sorry man, but I have no idea about how you can use JavaScript to access the shell of a Sun server because I never had anything else installed on my PC but Windows (XP & Vista)...
Why not using php to do that? There are lots and lots of good mail scripts out there you can use.
Download the new JavaScript Framework:
JUNE FrameworkSupport forum:
JUNE Forum