I assume you have an email form in html and you want to send mail as CGI-BIN.
So first, in javascript, you restrict the "from" email address to not include "bobby@;drop table email", which can be bypassed, and thus, must be untainted again, by say, some save and nice email parsing perl modules (that will validate your email address and do the same thing sendmail/mailx would do, send an email).
Both Strawberry Perl and ActiveState Perl allow CPAN. Read more on one of them in this node:
Sending Mail trough Perl using ActivePerl on windows