For sake of the completeness, I am posting here the full "ugly-but-it-works" solution (with the amends that, in its final form, it sends emails to more people, as well as provides an attachment):
cd "$(dirname "$0")" working_dir=$(pwd) # switching to the folder this script has been started from cvs_domain=mail.org cvs_mail_server=mail.${cvs_domain} cvs_port=25 [email protected] cvs_recipients=([email protected] [email protected]) cvs_delimiter=-----nEXt_paRt_frontier!!VSFCDVGGERHERZZ@$%^zzz--- # MIME multi-part delimiter, do not change { echo HELO $cvs_domain; sleep 1 # set up the email (sender, receivers): echo MAIL FROM:$cvs_sender; sleep 1 for r in ${cvs_recipients[@]}; do echo RCPT TO:$r; sleep 1 done echo DATA; sleep 1 echo From:$cvs_sender; sleep 1 for r in ${cvs_recipients[@]}; do echo To:$r; sleep 1 done echo Subject:Test for build; sleep 1 # build the mail structure, according to the MIME standard: echo MIME-Version: 1.0; sleep 1 echo "Content-Type: multipart/mixed; boundary=\"$cvs_delimiter\""; sleep 1 echo --${cvs_delimiter}; sleep 1 echo Content-Type: text/plain; sleep 1 echo; sleep 1 echo Don\'t panic. This is only a test.; sleep 1 echo; sleep 1 echo --${cvs_delimiter}; sleep 1 echo "Content-Type: text/plain; name=\"test.txt\""; sleep 1 echo "Content-Disposition: attachment; filename=\"test.txt\""; sleep 1 echo "Content-Transfer-Encoding: base64"; sleep 1 echo; sleep 1 encoded_file=$( base64 ./change.log ) # encoding the contents of the file, according to the declaration above echo "$encoded_file"; sleep 1 echo; sleep 1 echo --${cvs_delimiter}; sleep 1 echo .; sleep 1 echo QUIT sleep 1; } | telnet $cvs_mail_server $cvs_port
One may choose to fiddle with the delays. And, for (what I think may be) a more robust solution, I would go with expect(1).