UNIX script with smtp and telnet

hi,
i have a problem ,

I'm creating a script that send a mail with telnet .
via command line it's ok,but i create the .sh i have problem .
this a .sh

telnet
open mysmtp 25
HELO
sleep 15
MAIL FROM:<Email>
sleep 15
RCPT TO:<email>
sleep 15
DATA

SUBJECT : PROVA

PROVA
CIAO
PROVA
.

QUIT
quit

Whats the problem and how are you running the script?

i running the .sh and
i receive this output :

pippo.sh
telnet>

You need to use stdin redirection

Something like:

#!/usr/bin/ksh
telnet <<EndOfMail
open mysmtp  25
HELO
sleep 15
MAIL FROM:<Email>
sleep 15
RCPT TO:<email>
sleep 15
DATA


SUBJECT : PROVA

PROVA
CIAO
PROVA
.
EndOfMail

Hope this helps.