man sendmail should give you an idea on how to use it.
Basically you just pipe the email data to it directly.
Just make sure the format is correct.
Something like:
To: user@somewhere
From: me@overhere
body data
EOF
is usually enough.
But read the manual to get the full info.
Oh, and make sure, I mean really sure, that what you are passing to sendmail
does can not have any naughty commands in it, or you could be giving a hacker some serious opportunities.