Use Expect for SMTP testing
Thu Jul 10, 2008 · 82 words

I learned about Expect from a past ADC video session about OS X deployment. Here's a very practical use for it - testing an SMTP server. Just run it with expect filename.

spawn telnet smtpserver 25
expect "220 "
send "MAIL FROM:test@example.com\r"
expect "250 Ok$"
send "RCPT TO:testuser@server\r"
expect "250 Ok$"
send "DATA\r"
expect "354"
send "From: "SMTP Test" <test@example.com>
Subject: This is a test
Date: Wed, 02 Jul 2008 15:08:43 +0000
Body of test message r.\r"
expect "250 Ok$"
send "QUIT\r"

back · essays · credits ·