A year ago I had to automate connection to SMTP server. I used telnet and a little bash magic.
Code:
( echo open localhost 25}
echo "ehlo example.org"
echo "mail from: test1@example.org"
echo "rcpt to: test2@example.org"
echo "data"
echo "Subject: Test Message"
echo ""
echo "."
echo "quit"
echo exit ) | telnet
You can put `sleep <seconds>' between echo statements to delay execution.