call a shell builtin
if you really want to build your own its
**********************************
telnet mailmachine 25
mail from: bill@blackbops.org
rcpt to: todd@blackops.org
data
this is your new passwd "fromme"
bye, whatever
.

"end conversation" note the empty return a bove bye and below the period that indicates the data portion of the mail conversation is finished.
HTH
bill