#!/usr/bin/expect set timeout -1 spawn telnet mx.mydomain.ru 25 send "ehlo mysmtpserver.ru\r" expect "250-8BITMIME" send "MAIL FROM:\r" expect "250" #expect "250 2.1.0 Ok" send "RCPT TO:\r" expect "250" #expect "250 2.1.5 Ok" send "data\r" expect "354 End data with ." send "Test message\r" send ".\r" expect "Ok" send "quit\r"