If you're making no assumptions other than having Perl
installed, as some systems are shipped in a condition that
can only be described as being both
spartan and antiquated, then you've got the right idea.
If you're willing to allow for modules, you could use something
like
Mail::Sender.
It is quite trivial to write an SMTP application like
that module, using
IO::Socket to help you out. However,
you will not get the same reliability as you would with
/bin/mail, since you will have to handle your own retries.