Automating mailing via telnet to smtp

Hi,

I am trying to write a ksh script to send an attachment via telnet to an SMTP server.

I'm using MKS Toolkit. mail, mailx, sendmail, nc are not working on the server where I have MKS Toolkit installed.

If I type the following from the command prompt I receive an email:

telnet x.com 25
helo a
mail from:Scripts@x.com
rcpt to:i@g.com
data
test
.

But if I use the following then I get the result given below:
Input:

(sleep 1
echo 'helo a'
sleep 1
echo 'mail from:<scripts@x.com>'
sleep 1
echo "rcpt to:<i@g.com>"
sleep 1
echo "data
test"
sleep 1
echo "."
sleep 1
echo "quit") | telnet x.com 25

Output:

Welcome to Microsoft Telnet Client
Escape Character is 'CTRL+]'

Microsoft Telnet> echo: writing: The pipe is being closed.
echo: writing: The pipe is being closed.
echo: writing: The pipe is being closed.
echo: writing: The pipe is being closed.
echo: writing: The pipe is being closed.
echo: writing: The pipe is being closed.
$

I am not receiving an e-mail. I want to use ksh because the rest of my script is in ksh.

Please help!

Thanks in advance!