#!/bin/sh
# url: http://pank.org/scripts/
# description: bash tcp sample code that send mail
# comment: bash
# platform: all

SMTP=msa.hinet.net
FROM=foo@msa.hinet.net
TO=bar@emax.net.tw
SUBJECT="BASH TCP test"
DATA="blah blah"

exec 5<> /dev/tcp/$SMTP/25
echo ehlo 0 >&5
echo mail from: $FROM >&5
echo rcpt to: $TO >&5
printf "data\nSubject: $SUBJECT\nTo: $TO\n$DATA\n.\n" >&5
echo quit >&5
cat <&5
exec 5>&-